pub struct ExponentialHistogram { /* private fields */ }Expand description
An auto-scaling histogram approximation implementation following the opentelemetry exponential histogram algorithm.
Implementations§
Source§impl ExponentialHistogram
impl ExponentialHistogram
Sourcepub fn new(desired_scale: u8) -> Self
pub fn new(desired_scale: u8) -> Self
Desired scale will drop as necessary to match the static max buckets configuration. This will happen dynamically in response to observed range. If your distribution range falls within 160 contiguous buckets somewhere the desired scale’s range, then your output scale will match your desired scale. If your observed range exceeds 160 buckets then scale will be reduced to reflect the data’s width.
Sourcepub fn new_with_max_buckets(desired_scale: u8, max_buckets: u16) -> Self
pub fn new_with_max_buckets(desired_scale: u8, max_buckets: u16) -> Self
Desired scale will drop as necessary to match the static max buckets configuration. This will happen dynamically in response to observed range. If your distribution range falls within max_buckets contiguous buckets somewhere the desired scale’s range, then your output scale will match your desired scale. If your observed range exceeds max_buckets then scale will be reduced to reflect the data’s width.
Sourcepub fn accumulate<T: Into<f64>>(&mut self, value: T)
pub fn accumulate<T: Into<f64>>(&mut self, value: T)
Observe a value, increasing its bucket’s count by 1
Sourcepub fn sum(&self) -> f64
pub fn sum(&self) -> f64
This is an approximation, just using the positive buckets for the sum.
Sourcepub fn min(&self) -> f64
pub fn min(&self) -> f64
This is an approximation, just using the positive buckets for the min.
Sourcepub fn max(&self) -> f64
pub fn max(&self) -> f64
This is an approximation, just using the positive buckets for the max.
Sourcepub fn scale(&self) -> u8
pub fn scale(&self) -> u8
What is the current scale (as defined by opentelemetry exponential histogram)?
Sourcepub fn bucket_start_offset(&self) -> usize
pub fn bucket_start_offset(&self) -> usize
What is the current bucket start offset (as defined by opentelemetry exponential histogram)?
Sourcepub fn take_counts(self) -> (VecDeque<usize>, VecDeque<usize>)
pub fn take_counts(self) -> (VecDeque<usize>, VecDeque<usize>)
Remove and return (positive, negative) bucket counts per the opentelemetry histogram concept.
Remember that index 0 is actually the bucket_start_offset()’th bucket (as defined by opentelemetry exponential histogram).
Sourcepub fn has_negatives(&self) -> bool
pub fn has_negatives(&self) -> bool
Are there any negative observations?
Sourcepub fn value_counts(&self) -> impl Iterator<Item = (f64, usize)> + '_
pub fn value_counts(&self) -> impl Iterator<Item = (f64, usize)> + '_
Iterate pairs of bucket->count. The bucket thresholds are defined by the opentelemetry exponential histogram format. You do not need to do any extra math, this walks the actual mapping of bucket-to-count.
Trait Implementations§
Source§impl Clone for ExponentialHistogram
impl Clone for ExponentialHistogram
Source§fn clone(&self) -> ExponentialHistogram
fn clone(&self) -> ExponentialHistogram
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more