pub struct ScoreHistogram { /* private fields */ }Expand description
Fixed-bin histogram over an f64 stream.
Implementations§
Source§impl ScoreHistogram
impl ScoreHistogram
Sourcepub fn new(config: HistogramConfig) -> RcfResult<Self>
pub fn new(config: HistogramConfig) -> RcfResult<Self>
Build a fresh histogram with the supplied config.
§Errors
Forwards HistogramConfig::validate errors.
Sourcepub fn with_range(min: f64, max: f64) -> RcfResult<Self>
pub fn with_range(min: f64, max: f64) -> RcfResult<Self>
Sourcepub fn bin_edges(&self) -> Vec<(f64, f64)>
pub fn bin_edges(&self) -> Vec<(f64, f64)>
Inclusive/exclusive edges of every bin — [(min_0, max_0), (min_1, max_1), …]. Useful for Prometheus-style export
where each bucket is named by its upper bound.
Sourcepub fn config(&self) -> &HistogramConfig
pub fn config(&self) -> &HistogramConfig
Configured bin layout.
Sourcepub fn underflow(&self) -> u64
pub fn underflow(&self) -> u64
Observations below HistogramConfig::min.
Sourcepub fn overflow(&self) -> u64
pub fn overflow(&self) -> u64
Observations at or above HistogramConfig::max.
Sourcepub fn non_finite(&self) -> u64
pub fn non_finite(&self) -> u64
Non-finite observations (NaN, ±∞).
Sourcepub fn total(&self) -> u64
pub fn total(&self) -> u64
Total number of record calls — sum of every bin,
underflow, overflow, and non-finite.
Sourcepub fn merge(&mut self, other: &Self) -> RcfResult<()>
pub fn merge(&mut self, other: &Self) -> RcfResult<()>
Merge other into self. Both histograms must share the
exact same config.
§Errors
Returns RcfError::InvalidConfig when the configs differ.
Sourcepub fn percentile(&self, p: f64) -> Option<f64>
pub fn percentile(&self, p: f64) -> Option<f64>
Linear-interpolated percentile of the recorded values.
Returns None when p is outside [0, 1] or the histogram
has seen no in-range observations. Under-/overflow and
non-finite counts are excluded from the percentile.
Trait Implementations§
Source§impl Clone for ScoreHistogram
impl Clone for ScoreHistogram
Source§fn clone(&self) -> ScoreHistogram
fn clone(&self) -> ScoreHistogram
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScoreHistogram
impl Debug for ScoreHistogram
Source§impl<'de> Deserialize<'de> for ScoreHistogram
impl<'de> Deserialize<'de> for ScoreHistogram
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>,
Source§impl PartialEq for ScoreHistogram
impl PartialEq for ScoreHistogram
Source§impl Serialize for ScoreHistogram
impl Serialize for ScoreHistogram
impl StructuralPartialEq for ScoreHistogram
Auto Trait Implementations§
impl Freeze for ScoreHistogram
impl RefUnwindSafe for ScoreHistogram
impl Send for ScoreHistogram
impl Sync for ScoreHistogram
impl Unpin for ScoreHistogram
impl UnsafeUnpin for ScoreHistogram
impl UnwindSafe for ScoreHistogram
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more