pub struct Histogram { /* private fields */ }Expand description
OpenMetrics Histogram to track distributions of values.
Implementations§
Source§impl Histogram
 
impl Histogram
Sourcepub fn new(buckets: Vec<f64>) -> Self
 
pub fn new(buckets: Vec<f64>) -> Self
Constructs a new histogram with the given bucket boundaries.
The buckets parameter defines the upper bounds for each bucket.
Buckets should be in ascending order. An infinity bucket is automatically
added if not present to ensure all observations are captured.
Sourcepub fn buckets(&self) -> Vec<(f64, u64)>
 
pub fn buckets(&self) -> Vec<(f64, u64)>
Returns the bucket counts as a vector of (upper_bound, cumulative_count) pairs.
The counts are cumulative, meaning each bucket contains the count of all observations less than or equal to its upper bound.
Sourcepub fn percentile(&self, p: f64) -> f64
 
pub fn percentile(&self, p: f64) -> f64
Calculates the approximate percentile value.
Returns the bucket upper bound where the percentile falls.
For example, percentile(0.99) returns the p99 value.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Histogram
 
impl<'de> Deserialize<'de> for Histogram
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Histogram
impl RefUnwindSafe for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnwindSafe for Histogram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more