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

Directly implement Measure trait for metric aggregates #2371

Merged

Conversation

fraillt
Copy link
Contributor

@fraillt fraillt commented Dec 2, 2024

Prerequisite for #2328
This PR is similar to #2425, but it's for measurement instead of collection.

Changes

  • created AttributeSetFilter utility that (depending on provided filtering function) applies filter to attribute-sets before measurement. Similar logic as in AggregateBuilder::filter
  • store AttributeSetFilter as part of aggregate
  • aggregates directly implement Measure trait.

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 December 2, 2024 07:43
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.8%. Comparing base (fbcba3b) to head (d26f3ab).
Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2371   +/-   ##
=====================================
  Coverage   76.8%   76.8%           
=====================================
  Files        122     122           
  Lines      21823   21851   +28     
=====================================
+ Hits       16772   16797   +25     
- Misses      5051    5054    +3     

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

@fraillt fraillt force-pushed the directly-implement-measure-trait branch from 00bee01 to ea75ca6 Compare December 13, 2024 20:54
@fraillt fraillt force-pushed the directly-implement-measure-trait branch from ea75ca6 to e939d1a Compare December 18, 2024 07:01
pub(crate) fn apply(&self, attrs: &[KeyValue], run: impl FnOnce(&[KeyValue])) {
if let Some(filter) = &self.filter {
let filtered_attrs: Vec<KeyValue> =
attrs.iter().filter(|kv| filter(kv)).cloned().collect();
Copy link
Member

Choose a reason for hiding this comment

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

filtering is supposed to help reduce cost (including perf cost), but unfortunately, filtering path need heap allocations. Nothing introduced in this PR, but just mentioning as something we can fix in the future.

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.

LGTM!
Wondering if there any measurable difference in performance?

@cijothomas cijothomas merged commit 0605341 into open-telemetry:main Dec 18, 2024
21 checks passed
@fraillt fraillt deleted the directly-implement-measure-trait branch January 1, 2025 14:42
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