pub struct AtomicWindowedHistogram { /* private fields */ }Expand description
An atomic windowed histogram.
This histogram provides a windowed view of values that rolls forward over time, dropping old values as they exceed the window of the histogram. Writes into the histogram are lock-free, as well as snapshots of the histogram.
Implementations§
Source§impl AtomicWindowedHistogram
impl AtomicWindowedHistogram
Sourcepub fn new(window: Duration, granularity: Duration, clock: Clock) -> Self
pub fn new(window: Duration, granularity: Duration, clock: Clock) -> Self
Creates a new AtomicWindowedHistogram.
Internally, a number of buckets will be created, based on how many times granularity goes
into window. As time passes, buckets will be cleared to avoid values older than the
window duration.
As buckets will hold values represneting a period of time up to granularity, the
granularity can be lowered or raised to roll values off more precisely, or less precisely,
against the provided clock.
§Panics
Panics if granularity is larger than window.
Sourcepub fn snapshot(&self) -> StreamingIntegers
pub fn snapshot(&self) -> StreamingIntegers
Takes a snapshot of the current histogram.
Returns a StreamingIntegers value, representing all observed values in the
histogram. As writes happen concurrently, along with buckets being cleared, a snapshot is
not guaranteed to have all values present at the time the method was called.