fix: drop +Inf bound from OpenTelemetry classic histogram boundaries - #2458
Merged
zeitlinger merged 2 commits intoSep 14, 2026
Merged
Conversation
OpenTelemetry explicit bucket boundaries must be finite, with the +Inf bucket implicit (counts.size() == boundaries.size() + 1). PrometheusClassicHistogram.makeBoundaries() copied the trailing +Inf upper bound, so the exported HistogramPointData had as many counts as boundaries and the OTLP explicit_bounds contained Infinity. Skip the +Inf bound; the non-cumulative counts already end with the +Inf bucket count. Signed-off-by: KR Ravindra <42912207+KR-Ravindra@users.noreply.github.com>
Contributor
Author
|
Round 1 self-review. Verified against
No duplicate: #2416 cross-references only this PR. Marking ready. |
KR-Ravindra
marked this pull request as ready for review
September 13, 2026 06:56
KR-Ravindra
requested review from
dhoard,
fstab,
jaydeluca and
zeitlinger
as code owners
September 13, 2026 06:56
zeitlinger
approved these changes
Sep 14, 2026
zeitlinger
left a comment
Member
There was a problem hiding this comment.
Verified that ClassicHistogramBuckets always has one sorted final +Inf bucket with non-cumulative counts. Dropping only that explicit boundary while retaining its count satisfies the OTel counts = boundaries + 1 contract, and the SDK-construction plus OTLP serialization tests cover the model and wire representation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Classic histograms exported through the OpenTelemetry bridge carry the Prometheus
+Infupperbound inside
HistogramPointData.getBoundaries(), andgetCounts()has the same length asgetBoundaries(). The OpenTelemetry data model expects finite explicit bounds withcounts.size() == boundaries.size() + 1(the+Infbucket is implicit).Root cause
PrometheusClassicHistogram.makeBoundaries()(
prometheus-metrics-exporter-opentelemetry/.../otelmodel/PrometheusClassicHistogram.java:70-76)copies every
ClassicHistogramBucketsupper bound, including the trailing+Inf.makeCounts()is already correct:ClassicHistogramBucketscounts are non-cumulative and thelast entry is the
+Infbucket count.Fix
Skip the
+Infupper bound inmakeBoundaries(). Counts are unchanged, so for Prometheusbuckets
[1, 5, +Inf]/[c0, c1, c2]the OTel point is now boundaries[1, 5],counts
[c0, c1, c2], totalc0 + c1 + c2(as described in #2416).The existing
ExportTest.histogramexpectationhasBucketBoundaries(1, 2, 3, +Inf)encodedthe old behaviour and is updated to
hasBucketBoundaries(1, 2, 3); itshasBucketCounts(1, 0, 0, 0)is unchanged.How tested
New
PrometheusClassicHistogramTest(buckets[1, 5, +Inf], counts[2, 3, 4]) checks theHistogramPointData, feeds it through the OTel SDK's ownImmutableHistogramPointData.createvalidation, and parses the OTLP payload produced by
MetricsRequestMarshaler.Before the fix:
After the fix (
./mvnw test -pl prometheus-metrics-exporter-opentelemetry -Dcoverage.skip=true):Links
This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.