Skip to content

Commit b3a3977

Browse files
authored
Merge branch 'main' into logrecord-state-processor
2 parents 299bc6a + 7eeae5b commit b3a3977

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## Unreleased
44

55
* Export OpenMetrics format from Prometheus exporters ([#5107](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5107))
6-
* For requests with OpenMetrics format, scope info is automatically added ([#5086](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5086))
6+
* For requests with OpenMetrics format, scope info is automatically added
7+
([#5086](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5086)
8+
[#5182](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5182))
79

810
## 1.7.0-rc.1
911

src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## Unreleased
44

55
* Export OpenMetrics format from Prometheus exporters ([#5107](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5107))
6-
* For requests with OpenMetrics format, scope info is automatically added ([#5086](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5086))
6+
* For requests with OpenMetrics format, scope info is automatically added
7+
([#5086](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5086)
8+
[#5182](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5182))
79

810
## 1.7.0-rc.1
911

src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusCollectionManager.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,31 +172,34 @@ private ExportResult OnCollect(Batch<Metric> metrics)
172172

173173
try
174174
{
175-
this.scopes.Clear();
176-
177-
foreach (var metric in metrics)
175+
if (this.exporter.OpenMetricsRequested)
178176
{
179-
if (PrometheusSerializer.CanWriteMetric(metric))
177+
this.scopes.Clear();
178+
179+
foreach (var metric in metrics)
180180
{
181-
if (this.scopes.Add(metric.MeterName))
181+
if (PrometheusSerializer.CanWriteMetric(metric))
182182
{
183-
try
183+
if (this.scopes.Add(metric.MeterName))
184184
{
185-
cursor = PrometheusSerializer.WriteScopeInfo(this.buffer, cursor, metric.MeterName);
185+
try
186+
{
187+
cursor = PrometheusSerializer.WriteScopeInfo(this.buffer, cursor, metric.MeterName);
186188

187-
break;
188-
}
189-
catch (IndexOutOfRangeException)
190-
{
191-
if (!this.IncreaseBufferSize())
189+
break;
190+
}
191+
catch (IndexOutOfRangeException)
192192
{
193-
// there are two cases we might run into the following condition:
194-
// 1. we have many metrics to be exported - in this case we probably want
195-
// to put some upper limit and allow the user to configure it.
196-
// 2. we got an IndexOutOfRangeException which was triggered by some other
197-
// code instead of the buffer[cursor++] - in this case we should give up
198-
// at certain point rather than allocating like crazy.
199-
throw;
193+
if (!this.IncreaseBufferSize())
194+
{
195+
// there are two cases we might run into the following condition:
196+
// 1. we have many metrics to be exported - in this case we probably want
197+
// to put some upper limit and allow the user to configure it.
198+
// 2. we got an IndexOutOfRangeException which was triggered by some other
199+
// code instead of the buffer[cursor++] - in this case we should give up
200+
// at certain point rather than allocating like crazy.
201+
throw;
202+
}
200203
}
201204
}
202205
}

test/OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests/PrometheusExporterMiddlewareTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ private static async Task RunPrometheusExporterMiddlewareIntegrationTest(
328328
+ "# TYPE counter_double_total counter\n"
329329
+ $"counter_double_total{{otel_scope_name='{MeterName}',otel_scope_version='{MeterVersion}',key1='value1',key2='value2'}} 101.17 (\\d+\\.\\d{{3}})\n"
330330
+ "# EOF\n"
331-
: "# TYPE otel_scope_info info\n"
332-
+ "# HELP otel_scope_info Scope metadata\n"
333-
+ $"otel_scope_info{{otel_scope_name='{MeterName}'}} 1\n"
334-
+ "# TYPE counter_double_total counter\n"
331+
: "# TYPE counter_double_total counter\n"
335332
+ $"counter_double_total{{otel_scope_name='{MeterName}',otel_scope_version='{MeterVersion}',key1='value1',key2='value2'}} 101.17 (\\d+)\n"
336333
+ "# EOF\n";
337334

test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,7 @@ private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetri
176176
+ "# TYPE counter_double_total counter\n"
177177
+ $"counter_double_total{{otel_scope_name='{MeterName}',otel_scope_version='{MeterVersion}',key1='value1',key2='value2'}} 101.17 (\\d+\\.\\d{{3}})\n"
178178
+ "# EOF\n"
179-
: "# TYPE otel_scope_info info\n"
180-
+ "# HELP otel_scope_info Scope metadata\n"
181-
+ $"otel_scope_info{{otel_scope_name='{MeterName}'}} 1\n"
182-
+ "# TYPE counter_double_total counter\n"
179+
: "# TYPE counter_double_total counter\n"
183180
+ $"counter_double_total{{otel_scope_name='{MeterName}',otel_scope_version='{MeterVersion}',key1='value1',key2='value2'}} 101.17 (\\d+)\n"
184181
+ "# EOF\n";
185182

0 commit comments

Comments
 (0)