pub struct MeasurementSummary { /* private fields */ }Expand description
Canonical shared arithmetic for local diagnostic summaries and distributions.
Re-exported so callers can name returned summaries without selecting a separate Metrics dependency. This is the shared type, with no local wrapper or arithmetic. Ordered observations with a mergeable aggregate and a separate latest value.
Count and total saturate independently, tracking actual overflow. An exactly
reached u64::MAX remains exact; inspect the aggregate’s saturation flags
before using raw counts/totals for exact arithmetic. Latest and maximum remain
individual observations after overflow. Empty and measured zero are distinct.
Consumers own units, identity, ordering and reset boundaries.
Implementations§
Source§impl MeasurementSummary
impl MeasurementSummary
Sourcepub const EMPTY: MeasurementSummary
pub const EMPTY: MeasurementSummary
Empty summary, with no latest or maximum observation.
Sourcepub const fn record(&mut self, value: u64)
pub const fn record(&mut self, value: u64)
Record one completed observation, including zero, in the existing unit.
Sourcepub const fn aggregate(self) -> MeasurementAggregate
pub const fn aggregate(self) -> MeasurementAggregate
Mergeable count/total/maximum snapshot without observation ordering.
Sourcepub const fn samples(self) -> u64
pub const fn samples(self) -> u64
Sample count, clipped at u64::MAX; saturation is in Self::aggregate.
Sourcepub const fn total(self) -> u64
pub const fn total(self) -> u64
Observation total, clipped at u64::MAX; saturation is in Self::aggregate.
Sourcepub const fn mean(self) -> Result<Option<u64>, MeasurementMeanError>
pub const fn mean(self) -> Result<Option<u64>, MeasurementMeanError>
Floor-rounded mean, or None when empty. An exactly reached cap is valid.
§Errors
Returns MeasurementMeanError on actual count or total overflow.
Trait Implementations§
Source§impl Clone for MeasurementSummary
impl Clone for MeasurementSummary
Source§fn clone(&self) -> MeasurementSummary
fn clone(&self) -> MeasurementSummary
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more