pub struct Aggregator { /* private fields */ }
Expand description
A collector of Bucket
submissions.
§Aggregation
Each metric is dispatched into the a Bucket
depending on its project key (DSN), name, type,
unit, tags and timestamp. The bucket timestamp is rounded to the precision declared by the
bucket_interval
field on the AggregatorConfig configuration.
Each bucket stores the accumulated value of submitted metrics:
Counter
: Sum of values.Distribution
: A list of values.Set
: A unique set of hashed values.Gauge
: A summary of the reported values, seeGaugeValue
.
§Conflicts
Metrics are uniquely identified by the combination of their name, type and unit. It is allowed to send metrics of different types and units under the same name. For example, sending a metric once as set and once as distribution will result in two actual metrics being recorded.
Implementations§
source§impl Aggregator
impl Aggregator
sourcepub fn named(name: String, config: &AggregatorConfig) -> Self
pub fn named(name: String, config: &AggregatorConfig) -> Self
Creates a new named Self
.
sourcepub fn merge(
&mut self,
project_key: ProjectKey,
bucket: Bucket,
) -> Result<(), AggregateMetricsError>
pub fn merge( &mut self, project_key: ProjectKey, bucket: Bucket, ) -> Result<(), AggregateMetricsError>
Merge a bucket into this aggregator.
sourcepub fn try_flush_next(&mut self, now: SystemTime) -> Result<Partition, Duration>
pub fn try_flush_next(&mut self, now: SystemTime) -> Result<Partition, Duration>
Attempts to flush the next batch from the aggregator.
If it is too early to flush the next batch, the error contains the timestamp when the flush should be retried. After a successful flush, retry immediately until an error is returned with the next flush time, this makes sure time is eventually synchronized.
sourcepub fn next_flush_at(&mut self, now: SystemTime) -> Duration
pub fn next_flush_at(&mut self, now: SystemTime) -> Duration
Returns when the next partition is ready to be flushed using Self::try_flush_next
.
sourcepub fn into_partitions(self) -> impl Iterator<Item = Partition>
pub fn into_partitions(self) -> impl Iterator<Item = Partition>
Consumes the aggregator and returns all contained partitions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Aggregator
impl RefUnwindSafe for Aggregator
impl Send for Aggregator
impl Sync for Aggregator
impl Unpin for Aggregator
impl UnwindSafe for Aggregator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more