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

Incorrect MetricType of GaugeMetricAggregator - PATCH ATTACHED #2309

Closed
litvindev opened this issue Sep 3, 2021 · 3 comments
Closed

Incorrect MetricType of GaugeMetricAggregator - PATCH ATTACHED #2309

litvindev opened this issue Sep 3, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@litvindev
Copy link

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

  1. Modify Console application from examples folder 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),
                };
            });
  1. Build and start Console application 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.
  1. 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

@litvindev litvindev added the bug Something isn't working label Sep 3, 2021
@cijothomas
Copy link
Member

Thanks for reporting the issue and offering fix! This is fixed in the metrics branch, and will be part of the alpha3 release!

@litvindev
Copy link
Author

litvindev commented Sep 6, 2021

Hello, Cijo, I have checked the 'metrics' branch but did not found any fix there.
And 'OpenTelemetry.Exporter.Prometheus' still does not work with System.Diagnostics.Metric.ObservableGauge parameterized with floating-point types.

Could you please reopen the task, and close it, when the fix is commited?

@cijothomas cijothomas self-assigned this Sep 7, 2021
@cijothomas
Copy link
Member

Hello, Cijo, I have checked the 'metrics' branch but did not found any fix there.
And 'OpenTelemetry.Exporter.Prometheus' still does not work with System.Diagnostics.Metric.ObservableGauge parameterized with floating-point types.

Could you please reopen the task, and close it, when the fix is commited?

The SDK side was handling this correctly, but prometheus was not. Fix is coming:
#2317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants