-
Notifications
You must be signed in to change notification settings - Fork 593
fix: ObservableCounter and ObservableUpDownCounter remove stale attribute combinations that are no longer observed #3248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3248 +/- ##
=======================================
- Coverage 80.8% 80.8% -0.1%
=======================================
Files 129 129
Lines 23203 23196 -7
=======================================
- Hits 18750 18743 -7
Misses 4453 4453 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…servableCounter and ObservableUpDownCounter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug where ObservableCounter and ObservableUpDownCounter would continue reporting stale attribute combinations that were no longer observed in subsequent measurement cycles. The fix ensures these instruments correctly report only data points from the current callback execution.
Key changes:
- Changed PrecomputedSum to use
collect_and_resetinstead ofcollect_readonlyfor cumulative temporality, ensuring stale attributes are removed - Updated tests to verify that no metrics are reported when callbacks don't observe any values
- Enhanced documentation for ValueMap collection methods to clarify usage patterns
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| opentelemetry-sdk/src/metrics/pipeline.rs | Updated comment to clarify that observable instruments use collect_and_reset to remove stale attributes |
| opentelemetry-sdk/src/metrics/internal/precomputed_sum.rs | Changed cumulative mode from collect_readonly to collect_and_reset, with explanatory comments |
| opentelemetry-sdk/src/metrics/internal/mod.rs | Enhanced documentation for collect_readonly and collect_and_reset methods explaining their usage patterns |
| opentelemetry-sdk/src/metrics/mod.rs | Removed should_not_emit parameter from test helper function, as all observable instruments now correctly remove stale attributes |
| opentelemetry-sdk/CHANGELOG.md | Added fix entry describing the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #3213
Changes
ObservableCounter and ObservableUpDownCounter now correctly report only data points from the current measurement cycle, removing stale attribute combinations that are no longer observed.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes