pub enum CounterDelta {
FirstSample,
Advanced {
delta: u64,
elapsed: Duration,
wrapped: bool,
},
Reset,
}Expand description
What one counter reading means relative to the previous one.
Returned by CounterTracker::observe for callers that need the raw
movement — running totals such as NetworkSnapshot::since_launch accumulate
deltas rather than rates. Callers that only want a rate use
CounterTracker::rate.
Variants§
FirstSample
There was no previous reading, so no delta exists yet.
§8.2 and §26: the first sample of delta-based data is warming up, and it is emphatically not zero.
Advanced
A validated, non-negative movement over a measured monotonic interval.
Fields
elapsed: DurationThe monotonic interval the movement happened in.
May be Duration::ZERO when two readings share a timestamp. The
delta is still valid as a total in that case, but no rate can be
derived from it (§8.1).
Reset
The counter moved backwards in a way no known width explains.
The tracker has already re-baselined on the offending reading, so the next reading produces a valid delta rather than a second reset (§8.2).
Implementations§
Source§impl CounterDelta
impl CounterDelta
Sourcepub fn rate(self) -> MetricState<Rate>
pub fn rate(self) -> MetricState<Rate>
The rate this delta represents, as a publishable metric state.
Sourcepub const fn advanced_by(self) -> Option<u64>
pub const fn advanced_by(self) -> Option<u64>
How far the counter moved, if this reading produced a usable movement.
Returns None for the first sample and for a reset, so a caller
accumulating a running total cannot add an invalid delta to it.
Trait Implementations§
Source§impl Clone for CounterDelta
impl Clone for CounterDelta
Source§fn clone(&self) -> CounterDelta
fn clone(&self) -> CounterDelta
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more