Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid copy MetricPoint in exporter #2338

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override ExportResult Export(in Batch<Metric> batch)

Console.WriteLine(msg.ToString());

foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
string valueDisplay = string.Empty;
StringBuilder tagsBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
sum.AggregationTemporality = OtlpMetrics.AggregationTemporality.Cumulative;
}

foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var dataPoint = new OtlpMetrics.NumberDataPoint
{
Expand Down Expand Up @@ -179,7 +179,7 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
sum.AggregationTemporality = OtlpMetrics.AggregationTemporality.Cumulative;
}

foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var dataPoint = new OtlpMetrics.NumberDataPoint
{
Expand All @@ -204,7 +204,7 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
case MetricType.LongGauge:
{
var gauge = new OtlpMetrics.Gauge();
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var dataPoint = new OtlpMetrics.NumberDataPoint
{
Expand All @@ -229,7 +229,7 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
case MetricType.DoubleGauge:
{
var gauge = new OtlpMetrics.Gauge();
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var dataPoint = new OtlpMetrics.NumberDataPoint
{
Expand Down Expand Up @@ -263,7 +263,7 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
histogram.AggregationTemporality = OtlpMetrics.AggregationTemporality.Cumulative;
}

foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var dataPoint = new OtlpMetrics.HistogramDataPoint
{
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Prometheus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Bug fixes
([#2289](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2289))
([#2309](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2309))

## 1.2.0-alpha2

Released 2021-Aug-24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void WriteMetricsCollection(this PrometheusExporter exporter, Stre
case MetricType.LongSum:
{
builder = builder.WithType(PrometheusCounterType);
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var metricValueBuilder = builder.AddValue();
metricValueBuilder = metricValueBuilder.WithValue(metricPoint.LongValue);
Expand All @@ -75,7 +75,7 @@ public static void WriteMetricsCollection(this PrometheusExporter exporter, Stre
case MetricType.DoubleSum:
{
builder = builder.WithType(PrometheusCounterType);
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var metricValueBuilder = builder.AddValue();
metricValueBuilder = metricValueBuilder.WithValue(metricPoint.DoubleValue);
Expand All @@ -95,7 +95,7 @@ public static void WriteMetricsCollection(this PrometheusExporter exporter, Stre
case MetricType.LongGauge:
{
builder = builder.WithType(PrometheusGaugeType);
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var metricValueBuilder = builder.AddValue();
metricValueBuilder = metricValueBuilder.WithValue(metricPoint.LongValue);
Expand All @@ -112,7 +112,7 @@ public static void WriteMetricsCollection(this PrometheusExporter exporter, Stre
case MetricType.DoubleGauge:
{
builder = builder.WithType(PrometheusGaugeType);
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var metricValueBuilder = builder.AddValue();
metricValueBuilder = metricValueBuilder.WithValue(metricPoint.DoubleValue);
Expand Down Expand Up @@ -146,7 +146,7 @@ public static void WriteMetricsCollection(this PrometheusExporter exporter, Stre
* myHistogram_bucket{tag1="value1",tag2="value2",le="+Inf"} 355 1629860660991
*/
builder = builder.WithType(PrometheusHistogramType);
foreach (var metricPoint in metric.GetMetricPoints())
foreach (ref var metricPoint in metric.GetMetricPoints())
{
var metricValueBuilderSum = builder.AddValue();
metricValueBuilderSum.WithName(metric.Name + PrometheusHistogramSumPostFix);
Expand Down