Skip to content

Conversation

@taisho6339
Copy link

@taisho6339 taisho6339 commented Nov 16, 2025

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

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@taisho6339 taisho6339 requested a review from a team as a code owner November 16, 2025 00:18
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: cijothomas / name: Cijo Thomas (5c6ad04)

@taisho6339 taisho6339 changed the title Remove stale attribute combinations that are no longer observed in ObservableCounter and ObservableUpDownCounter ObservableCounter and ObservableUpDownCounter remove stale attribute combinations that are no longer observed Nov 16, 2025
@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.8%. Comparing base (df412fe) to head (5c6ad04).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@taisho6339 taisho6339 changed the title ObservableCounter and ObservableUpDownCounter remove stale attribute combinations that are no longer observed fix: ObservableCounter and ObservableUpDownCounter remove stale attribute combinations that are no longer observed Nov 16, 2025
Copy link
Contributor

Copilot AI left a 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_reset instead of collect_readonly for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: observable counters and up-down counters always report all historical label set

2 participants