Skip to content

[bug] Cumulative Counts in Native Histogram #6749

@CraigKennedy

Description

@CraigKennedy

Package

OpenTelemetry.Api

Package Version

Package Name Version
OpenTelemetry.Api 1.12.0
OpenTelemetry 1.12.0

Runtime Version

net8.0

Description

The counter continually increases and queries from a grafana dashboard do not reflect the actual number of requests made in a given period.

Steps to Reproduce

Here is the code where I configure the metrics collection. I'm using a sidecar container running Grafana Alloy to ship the metrics to Grafana Cloud.

            telemetryBuilder.WithMetrics(builder =>
            {
                builder
                    .SetResourceBuilder(ResourceBuilder.CreateEmpty().AddAttributes(attrs))
                    .ConfigureResource(resource => resource.AddService(applicationName, autoGenerateServiceInstanceId: false))
                    .AddAspNetCoreInstrumentation()
                    .AddApplicationMetrics()
                    .AddOtlpExporter(options =>
                    {
                        options.Endpoint = new Uri(otlpExporterEndpoint);
                        options.Protocol = otlpProtocol;
                    });

                builder.AddView(instrument => instrument.GetType().GetGenericTypeDefinition() == typeof(Histogram<>)
                    ? new Base2ExponentialBucketHistogramConfiguration()
                    : null);
            });

When I try to visualize http_server_request_duration_seconds in grafana using the histogram view with the query histogram_count(rate(http_server_request_duration_seconds{http_route="v1/coo/{part}", region="us-east-1", http_response_status_code="200", environment="prod"}[$__rate_interval])), the value only ever increases (until an instance restart).

Here is a graph of the query shown above:
Image

Expected Result

I expect the query to provide actual observed requests over time.

Actual Result

The request count continually increases over time.

Additional Context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageNew issues which have not been classified or triaged by a community memberpkg:OpenTelemetry.ApiIssues related to OpenTelemetry.Api NuGet package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions