-
Notifications
You must be signed in to change notification settings - Fork 881
Incorrect MetricType of GaugeMetricAggregator - PATCH ATTACHED #2309
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Report
NuGet package: https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus/1.2.0-alpha2
Runtime version: 'net5.0'
Symptom
Currently 'OpenTelemetry.Exporter.Prometheus' do not work with System.Diagnostics.Metric.ObservableGauge<T> parameterized with floating-point types. It works only with integer types.
Reproduce
- Modify
Consoleapplication fromexamplesfolder as follows.
In 'TestPrometheusExporter.cs' replace the following lines:
ObservableGauge<long> gauge = MyMeter.CreateObservableGauge<long>(
"Gauge",
() =>
{
var tag1 = new KeyValuePair<string, object>("tag1", "value1");
var tag2 = new KeyValuePair<string, object>("tag2", "value2");
return new List<Measurement<long>>()
{
new Measurement<long>(RandomGenerator.Next(1, 1000), tag1, tag2),
};
});
with these lines:
ObservableGauge<double> gauge = MyMeter.CreateObservableGauge<double>(
"Gauge",
() =>
{
var tag1 = new KeyValuePair<string, object>("tag1", "value1");
var tag2 = new KeyValuePair<string, object>("tag2", "value2");
return new List<Measurement<double>>()
{
new Measurement<double>(RandomGenerator.Next(1, 1000), tag1, tag2),
};
});
- Build and start
Consoleapplication with 'prometheus' command line parameter. It will print the following lines:
OpenTelemetry Prometheus Exporter is making metrics available at http://localhost:9184/metrics/
Press Enter key to exit now or will exit automatically after 2 minutes.
- Open http://localhost:9184/metrics/ in Web-browser.
EXPECTED BEHAVIOR
There should be Gauge metrics like these:
# TYPE Gauge gauge
Gauge{tag1="value1",tag2="value2"} 601 1630658150131
OBSERVED BEHAVIOR
- Gauge metrics lines are missed.
- Web-server no longer responds, pressing the F5 key in web browser returns a blank page.
The patch with proposed fix
0001-Fixed-incorrect-MetricType-of-GaugeMetricAggregator.txt
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working