-
Notifications
You must be signed in to change notification settings - Fork 468
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 aggregate collector generic over temporality #2506
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2506 +/- ##
=====================================
Coverage 77.9% 77.9%
=====================================
Files 123 124 +1
Lines 22943 22963 +20
=====================================
+ Hits 17875 17900 +25
+ Misses 5068 5063 -5 ☔ View full report in Codecov by Sentry. |
f89f06b
to
09ebfdc
Compare
@@ -53,6 +53,14 @@ pub trait Aggregation: fmt::Debug + any::Any + Send + Sync { | |||
fn as_mut(&mut self) -> &mut dyn any::Any; | |||
} | |||
|
|||
/// Allow to access data points of an [Aggregation]. | |||
pub trait AggregationDataPoints { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait AggregationDataPoints { | |
pub(crate) trait AggregationDataPoints { |
/// Allow to access data points of an [Aggregation]. | ||
pub trait AggregationDataPoints { | ||
/// The type of data point in the aggregation. | ||
type Point; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name it DataPoint
.
type Point; | |
type DataPoint; |
const TEMPORALITY: Temporality; | ||
type Aggr: Aggregator; | ||
|
||
fn measure(&self, value: <Self::Aggr as Aggregator>::PreComputedValue, attributes: &[KeyValue]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's getting a bit too confusing with these new coupled traits. Could we separate the concerns here? Could we update Collector
trait to only have collect related methods and AggregateMap
trait to only have update related methods? You could then keep an impl
of both the traits as fields of ExpoHistogram
struct.
record_sum: bool, | ||
record_min_max: bool, | ||
pub(crate) struct ExpoHistogram<AC> { | ||
pub(crate) aggregate_collector: AC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to keep these fields private and use a new
method for creating the struct. These fields don't have to be changed after initializing the struct anyway.
Prerequisite for #2328
Changes
Provided several interfaces that allow to provide "ValueMap" implementation for specific temporality.
The key element is
Collector
(which implementsAggregateCollector
). It provides common functionality for all aggregations (Sum, LastValue, Histogram, etc...):This allow to have very clean concrete implementations. I have refactored
ExponentialHistogram
to use these new interfaces as an example.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes