Skip to content
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

Fix observable counter cumulative aggregation #1644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stormshield-fabs
Copy link

@stormshield-fabs stormshield-fabs commented Mar 26, 2024

Fixes #1517 (incorrect cumulative aggregation for observable counters).

Changes

The observable counters rely on PrecomputedSum that was using the same ValueMap implementation as Sum (its counterpart for synchronous counters), effectively adding all observations (also drastically reducing the counter range).

This PR specializes ValueMap with an O (operation) parameter so that observations can be performed with the correct semantics (AddAssign for synchronous counters, Assign for observable ones). It also updates the PrecomputedSum::cumulative aggregation to return the current value.

The tests (observable_counter_delta and observable_counter_cumulative) are from #1516 with tiny fixes.

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 (none)

@stormshield-fabs stormshield-fabs requested a review from a team as a code owner March 26, 2024 09:48
Copy link

linux-foundation-easycla bot commented Mar 26, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: stormshield-fabs (12e0a03)

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 99.45652% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 69.3%. Comparing base (f203b03) to head (3036e83).
Report is 24 commits behind head on main.

❗ Current head 3036e83 differs from pull request most recent head 12e0a03. Consider uploading reports for the commit 12e0a03 to get more accurate results

Files Patch % Lines
opentelemetry-sdk/src/metrics/internal/sum.rs 90.9% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1644   +/-   ##
=====================================
  Coverage   69.3%   69.3%           
=====================================
  Files        136     136           
  Lines      19637   19554   -83     
=====================================
- Hits       13610   13567   -43     
+ Misses      6027    5987   -40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cijothomas
Copy link
Member

CLA Not Signed

@stormshield-fabs Could you follow the EasyCLA process and sign it? It is a pre-req for any contributions to OpenTelemetry!

@stormshield-fabs
Copy link
Author

The CLA is still under review at my company, thanks for the heads up.

@stormshield-fabs stormshield-fabs force-pushed the fix-observable-counter-cumulative-aggregation branch 2 times, most recently from a6d6c0c to c2f39a3 Compare April 29, 2024 07:40
@stormshield-fabs
Copy link
Author

The CLA has been signed. I've rebased this PR and updated the changelog.

@stormshield-fabs stormshield-fabs force-pushed the fix-observable-counter-cumulative-aggregation branch from c2f39a3 to 12e0a03 Compare May 6, 2024 10:17
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.

ObservableCounter aggregation bug for cumulative
2 participants