ExponentialHistogram

Struct ExponentialHistogram 

Source
pub struct ExponentialHistogram { /* private fields */ }
Expand description

An auto-scaling histogram approximation implementation following the opentelemetry exponential histogram algorithm.

Implementations§

Source§

impl ExponentialHistogram

Source

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.

Source

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.

Source

pub fn reset(&mut self)

Reset this histogram to an empty state

Source

pub fn accumulate<T: Into<f64>>(&mut self, value: T)

Observe a value, increasing its bucket’s count by 1

Source

pub fn is_empty(&self) -> bool

True when there aren’t any measurements in this histogram

Source

pub fn count(&self) -> usize

How many observations have been made?

Source

pub fn sum(&self) -> f64

This is an approximation, just using the positive buckets for the sum.

Source

pub fn min(&self) -> f64

This is an approximation, just using the positive buckets for the min.

Source

pub fn max(&self) -> f64

This is an approximation, just using the positive buckets for the max.

Source

pub fn scale(&self) -> u8

What is the current scale (as defined by opentelemetry exponential histogram)?

Source

pub fn bucket_start_offset(&self) -> usize

What is the current bucket start offset (as defined by opentelemetry exponential histogram)?

Source

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).

Source

pub fn has_negatives(&self) -> bool

Are there any negative observations?

Source

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

Source§

fn clone(&self) -> ExponentialHistogram

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExponentialHistogram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExponentialHistogram

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for ExponentialHistogram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ExponentialHistogram

Source§

fn eq(&self, other: &ExponentialHistogram) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ExponentialHistogram

Source§

impl StructuralPartialEq for ExponentialHistogram

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.