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 numeric cap remains exact; inspect the aggregate’s overflow 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.
Project counts, totals, maximum and means through Self::aggregate, just
as for a histogram; this type adds ordered recording and Self::latest.
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 from_parts(
aggregate: MeasurementAggregate,
latest: Option<u64>,
) -> Result<MeasurementSummary, MeasurementStateError>
pub const fn from_parts( aggregate: MeasurementAggregate, latest: Option<u64>, ) -> Result<MeasurementSummary, MeasurementStateError>
Restore an admitted aggregate and its latest ordered observation.
The caller establishes identity and ordering; this validates numeric fields.
§Errors
Rejects absent/nonempty latest values, values above the maximum and observations inconsistent with the aggregate’s exact total. With an exact count, the other observations cannot contribute more than their maximum.
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.
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