Trait stats::prelude::Histogram

source ·
pub trait Histogram {
    // Required method
    fn add_value(&self, value: i64);

    // Provided methods
    fn add_repeated_value(&self, value: i64, nsamples: u32) { ... }
    fn flush(&self) { ... }
}
Expand description

Histogram is a type of stat that can aggregate data send to it into predefined buckets. Example aggregations are average, sum or P50 (percentile). The aggregation should also happen on an interval basis, since its rarely useful to see aggregated all-time stats of a service running for many days.

Required Methods§

source

fn add_value(&self, value: i64)

Adds value to the histogram. It is being aggregated based on ExportType

Provided Methods§

source

fn add_repeated_value(&self, value: i64, nsamples: u32)

You might want to call this method when you have a very hot counter to avoid some congestions on it. The default implementation simply calls add_value O(nsamples) times. If you have a performance-sensitive use case, check whether your Stats type has an O(1) implementation. Value is the value of a single samples and nsamples is the number of samples. Please notice that difference in the value semantic compared to Timeseries::add_value_aggregated.

source

fn flush(&self)

Flush any buffered data so that it is observable externally. Should only be used for testing.

Implementations on Foreign Types§

source§

impl<T> Histogram for Box<T>
where T: Histogram + ?Sized,

source§

fn add_value(&self, value: i64)

source§

fn add_repeated_value(&self, value: i64, nsamples: u32)

source§

fn flush(&self)

Implementors§