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

[Metrics][POC] Use Weak instead of Arc in Counter to respect MeterProvider shutdown #2497

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

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Jan 5, 2025

Towards #2442

Changes

  • Use Weak instead of Arc in instruments to respect MeterProvider shutdown

Note: This also requires MeterProvider instance to be valid for metrics to be emitted.

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)

Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.9%. Comparing base (82ed8e0) to head (68f4806).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2497   +/-   ##
=====================================
  Coverage   77.9%   77.9%           
=====================================
  Files        123     123           
  Lines      22888   22909   +21     
=====================================
+ Hits       17839   17860   +21     
  Misses      5049    5049           

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

}

/// Records an increment to the counter.
pub fn add(&self, value: T, attributes: &[KeyValue]) {
self.0.measure(value, attributes)
if let Some(inner) = self.0.upgrade() {
Copy link
Member

Choose a reason for hiding this comment

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

how much is the perf cost for this upgrade as opposed to storing Arc itself?

Copy link
Contributor Author

@utpilla utpilla Jan 6, 2025

Choose a reason for hiding this comment

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

There is a considerable perf cost. Check this #2442 (comment).

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.

2 participants