Repository navigation
[OpenTelemetry] Drop non-finite values from histogram aggregations - #7759
martincostello wants to merge 26 commits into
Conversation
Non-finite values are no longer included in histograms to avoid permanently poisoning cumulative histogram aggregations.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7759 +/- ##
==========================================
+ Coverage 93.09% 93.10% +0.01%
==========================================
Files 397 399 +2
Lines 23335 23604 +269
Branches 4359 4406 +47
==========================================
+ Hits 21724 21977 +253
- Misses 1103 1108 +5
- Partials 508 519 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Add PR number.
There was a problem hiding this comment.
🟡 Changes recommended
Filtering occurs after tagged metric-point allocation, allowing invalid measurements to consume cardinality and affect valid streams.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates histogram aggregation to drop non-finite measurements before aggregation.
Changes:
- Filters
NaNand infinities from histogram updates. - Adds regression coverage and updates Prometheus snapshots.
- Documents the behavior change.
File summaries
| File | Description |
|---|---|
src/OpenTelemetry/Metrics/MetricPoint/MetricPoint.cs |
Filters non-finite histogram values. |
src/OpenTelemetry/CHANGELOG.md |
Documents the behavior change. |
test/OpenTelemetry.Tests/Metrics/AggregatorTests.cs |
Adds cumulative histogram coverage. |
test/OpenTelemetry.Tests/Metrics/MetricTestData.cs |
Updates min/max expectations. |
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/snapshots/PrometheusSerializer.HistogramNaN.verified.txt |
Updates NaN output snapshot. |
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/snapshots/PrometheusSerializer.HistogramInfinities.verified.txt |
Updates infinity output snapshot. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull request dashboard statusWaiting on the author · refreshed 2026-10-28 13:24 UTC Move out of draft to request review. Status above doesn't look right?
|
- Do not consume cardinality slots for histograms when updating if only non-finite values. - Add missing test coverage.
There was a problem hiding this comment.
🟡 Changes recommended
The new test uses a banned constructor and removes coverage for streams containing only non-finite measurements.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Balanced
Add missing test coverage.
There was a problem hiding this comment.
🟢 Approval recommended
The implementation consistently filters invalid measurements before allocation and aggregation, with comprehensive regression coverage.
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0 new
- Review effort level: Balanced
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
I have created open-telemetry/opentelemetry-specification#5346 If you want to merge this PR shortly, I would suggest to narrow changes to the exponential histograms only. We can extend this, when we have clarification from spec team. |
No rush on merge, I just wanted some opinions on whether the changes were right with regards to the spec or not. Can wait on the outcome of open-telemetry/opentelemetry-specification#5346. |
|
Moving to draft until open-telemetry/opentelemetry-specification#5346 is resolved. |
Move entry.
Move entry back to Unreleased.
There was a problem hiding this comment.
🟡 Changes recommended
The exponential histogram comments incorrectly call negative values undefined and should instead describe them as rejected by this SDK path without changing the existing guard.
1 open issue
2 resolved since last review
Review effort: Balanced
Update comment to be more accurate.
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer confirmation is needed because the cited non-finite-value guidance covers exponential histograms, while dropping explicit-histogram counts and bucket observations would broaden SDK policy.
No open issues 🎉
1 resolved since last review
Review effort: Balanced



Changes
Non-finite values are no longer included in histograms to avoid permanently poisoning cumulative histogram aggregations.
From the metrics specification:
This was found from a scan of the repository using Claude Code - it seems correct to me given the above, unless there's some nuance I've missed.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)