Trait telemetry::plain::Histogram [] [src]

pub trait Histogram<T>: Clone {
    fn record_cb<F>(&self, _: F) where F: FnOnce() -> Option<T>;

    fn record(&self, value: T) { ... }
}

A plain histogram.

Histograms do not implement Sync, so an instance of Histogram cannot be shared by several threads. However, any histogram can be cloned as needed for concurrent use.

Performance

Cloning a histogram is relatively cheap, both in terms of memory and in terms of speed (most histograms weigh ~40bytes on a x86-64 architecture).

When the telemetry service is inactive, recording data to a histogram is very fast (essentially a dereference and an atomic fetch). When the telemetry service is active, the duration of recording data is comparable to the duration of sending a simple message to a Sender.

Required Methods

fn record_cb<F>(&self, _: F) where F: FnOnce() -> Option<T>

Record a value in this histogram, as provided by a callback.

If the service is currently inactive, this is a noop.

If the callback returns None, no value is recorded.

Provided Methods

fn record(&self, value: T)

Record a value in this histogram.

If the service is currently inactive, this is a noop.

Implementors