Trait telemetry::keyed::KeyedHistogram [] [src]

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

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

A family of histograms, indexed by some dynamic value. Use these to monitor families of values that cannot be determined at compile-time, e.g. add-ons, programs, etc.

Histograms do not implement Sync, so an instance of KeyedHistogram 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<(K, 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, key: K, value: T)

Record a value in this histogram.

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

Implementors