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 ComputeAggregation #2425

Merged

Conversation

fraillt
Copy link
Contributor

@fraillt fraillt commented Dec 13, 2024

Prerequisite for #2328

Currently part of aggregate measuring and collecting logic is scattered in several places:

  • in AggregateBuilder
    • attribute set filtering is applied during measurement
    • collection method is selected for specified temporality
  • in specific aggregate e.g. Sum
    • actual measurement is calculations are performed
    • actual collection happens, depending on which method was called in AggregateBuilder.

Instead we should implement all logic in one place (aggregate implementation e.g. Sum), and AggregateBuilder would be responsible only for initializing it.
This is especially important for #2328, because we want to be able to select specific implementation (depending on temporality) at compile time. The goal is to be able to initialize/build aggregation like this:

/// Builds a sum aggregate function input and output.
pub(crate) fn sum(&self, monotonic: bool) -> Arc<dyn Aggregate> {
  match self.temporality {
    Temporality::Delta => Arc::new(Sum::new(DeltaCollector::new(), monotinic)),
    _ => Arc::new(Sum::new(CumulativeCollector::new(), monotinic)),
  }
}

As a side effect this approach will also has less indirection which simplifies code, and might improve performance.

Changes

  • Temporality is now passed in to aggregation during creation
  • aggregations directly implements ComputeAggregation

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 13, 2024 20:17
@cijothomas
Copy link
Member

Oops just merged the startTime PR! Could you resolve conflicts

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.8%. Comparing base (551760b) to head (5afd526).
Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2425   +/-   ##
=====================================
  Coverage   76.8%   76.8%           
=====================================
  Files        122     122           
  Lines      21806   21823   +17     
=====================================
+ Hits       16758   16772   +14     
- Misses      5048    5051    +3     

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

@fraillt fraillt force-pushed the directly-implement-compute-aggregation branch from c2d13a1 to 65877a6 Compare December 15, 2024 09:33
@@ -118,7 +118,7 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/open-telemetry/opentelemetry-rust/main/assets/logo.svg"
)]
#![cfg_attr(test, deny(warnings))]
// #![cfg_attr(test, deny(warnings))]
Copy link
Member

Choose a reason for hiding this comment

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

nit: is this intentional?

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.

Good move!

@cijothomas cijothomas merged commit b9a422b into open-telemetry:main Dec 18, 2024
21 checks passed
@fraillt fraillt deleted the directly-implement-compute-aggregation branch December 18, 2024 06:00
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