Repository navigation
[OpenTelemetry] Fix empty histogram data points - #7923
Merged
Merged
Conversation
Set the `MetricPoint` status flag while still holding the histogram lock in the update paths, so that `TakeSnapshot` cannot observe a new value without also observing the flag. Previously, a collection that landed between an update releasing the lock and setting `CollectPending` cleared the flag, which the update then set again. The next collection exported an empty data point (count of zero, with infinite min and max). Sum and gauge aggregations are lock-free and still have the same benign race. Contributes to open-telemetry#7036.
Pull request dashboard statusMerged · refreshed 2026-10-14 19:29 UTC Status above doesn't look right?
|
martincostello
commented
Oct 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7923 +/- ##
==========================================
+ Coverage 92.25% 92.26% +0.01%
==========================================
Files 363 363
Lines 20990 20996 +6
==========================================
+ Hits 19364 19372 +8
+ Misses 1626 1624 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Add PR number.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new ordering can strand a concurrently offered exemplar in delta mode until a later measurement.
1 open finding
What changed in this PR
Fixes a race that could export empty delta histogram points.
Changes:
- Sets histogram collection status under the histogram lock.
- Adds regression coverage for histogram variants.
- Documents the behavioral fix.
| File | Description |
|---|---|
src/OpenTelemetry/Metrics/MetricPoint/MetricPoint.cs |
Moves status updates into histogram critical sections. |
test/OpenTelemetry.Tests/Metrics/MetricPointReclaimTests.cs |
Tests concurrent updates and collection. |
src/OpenTelemetry/CHANGELOG.md |
Records the bug fix. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Address review comments from GitHub Copilot.
Explain trade-off against a suggested refactoring by Codex.
rajkumar-rangaraj
approved these changes
Oct 14, 2026
This was referenced Oct 15, 2026
This was referenced Nov 16, 2026
Open
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.

Contributes to #7036.
Changes
Set the
MetricPointstatus flag while still holding the histogram lock in the update paths, so thatTakeSnapshotcannot observe a new value without also observing the flag.Previously, a collection that landed between an update releasing the lock and setting
CollectPendingcleared the flag, which the update then set again. The next collection exported an empty data point (count of zero, with infinite min and max).Sum and gauge aggregations are lock-free and still have the same benign race.
Running benchmarks locally show no performance impact from the changes.
Merge requirement checklist
CHANGELOG.mdfile(s) updated for non-trivial changesChanges in public API reviewed (if applicable)Footnotes
Yes, I can answer maintainer questions about the content of this PR without using AI. ↩