[Exporter.Prometheus] Fix OpenMetrics histograms#7221
Merged
martincostello merged 8 commits intoMay 5, 2026
Merged
Conversation
Omit histogram `_sum` and `_count` in OpenMetrics when negative bucket thresholds are present.
martincostello
commented
Apr 29, 2026
martincostello
commented
Apr 29, 2026
Update PR number.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7221 +/- ##
==========================================
- Coverage 89.98% 89.92% -0.06%
==========================================
Files 272 272
Lines 13643 13649 +6
==========================================
- Hits 12276 12274 -2
- Misses 1367 1375 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes OpenMetrics histogram serialization in the Prometheus exporters to comply with the OpenMetrics spec when explicit bucket boundaries include negative thresholds.
Changes:
- Detect negative histogram bucket bounds during serialization when OpenMetrics output is requested.
- Omit histogram
_sumand_countseries in OpenMetrics output when negative bucket thresholds are present. - Add a unit test validating
_sum/_countomission and update changelogs for both Prometheus exporters.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs | Adds coverage ensuring OpenMetrics output omits _sum and _count when buckets include negative bounds. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/PrometheusSerializerExt.cs | Implements conditional suppression of _sum/_count for OpenMetrics histograms with negative bucket thresholds. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md | Documents the behavioral change in the HttpListener exporter changelog. |
| src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md | Documents the behavioral change in the AspNetCore exporter changelog (shared serializer implementation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 tasks
Kielek
approved these changes
May 5, 2026
This was referenced Jun 10, 2026
Open
This was referenced Jun 11, 2026
Bump OpenTelemetry and OpenTelemetry.Exporter.OpenTelemetryProtocol
mishamyte/OpenTelemetry-Demo#488
Open
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.
Changes
Omit histogram
_sumand_countin OpenMetrics when negative bucket thresholds are present.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)