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

Add collect methods on ValueMap #2267

Merged
merged 7 commits into from
Nov 6, 2024

Conversation

fraillt
Copy link
Contributor

@fraillt fraillt commented Nov 2, 2024

Design discussion issue #2145

Changes

Mostly extract DataPoint collection logic from specific metrics implementations into ValueMap under collect_readonly and collect_and_reset functions.
I tried to preserve existing logic with few exceptions:

  • for cumulative temporality - acquire read lock on hashmap instead of write lock.
  • for delta temporality - since hashmap is cleared anyway, reduce the time hashmap is locked. Instead of "lock->iterate(consume)->unlock" changed to "lock->consume->unlock->iterate".

There are a lot more things that could be improved, but with this change it will become more convenient/simpler to experiment/implement further improvements in the future.

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)

@fraillt fraillt requested a review from a team as a code owner November 2, 2024 12:43
Copy link

codecov bot commented Nov 2, 2024

Codecov Report

Attention: Patch coverage is 98.52941% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.4%. Comparing base (1fd871a) to head (fc04691).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/metrics/internal/mod.rs 95.4% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2267     +/-   ##
=======================================
- Coverage   79.5%   79.4%   -0.2%     
=======================================
  Files        121     121             
  Lines      20978   20787    -191     
=======================================
- Hits       16685   16512    -173     
+ Misses      4293    4275     -18     

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

@fraillt fraillt changed the title add collect methods on ValueMap Add collect methods on ValueMap Nov 3, 2024
Copy link

linux-foundation-easycla bot commented Nov 3, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Contributor

@utpilla utpilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

There are two newer kinds of allocations happening with these changes as mentioned in #2267 (comment) and #2267 (comment). These can be avoided. I had a chat with @fraillt on Slack and he agreed to address these in his upcoming PRs.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looking forward to the follow up improvements.

@cijothomas cijothomas merged commit ac0ea9f into open-telemetry:main Nov 6, 2024
24 of 25 checks passed
@fraillt fraillt deleted the value-map-collect branch November 7, 2024 05:32
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.

4 participants