iroh_metrics

Struct Histogram

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

OpenMetrics Histogram to track distributions of values.

Implementations§

Source§

impl Histogram

Source

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.

Source

pub fn observe(&self, value: f64)

Records a value in the histogram.

Source

pub fn count(&self) -> u64

Returns the total count of observations.

Source

pub fn sum(&self) -> f64

Returns the sum of all observed values.

Source

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.

Source

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 Debug for Histogram

Source§

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

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

impl<'de> Deserialize<'de> for Histogram

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Metric for Histogram

Source§

fn type(&self) -> MetricType

Returns the type of this metric.
Source§

fn value(&self) -> MetricValue

Returns the current value of this metric.
Source§

fn as_any(&self) -> &dyn Any

Casts this metric to Any for downcasting to concrete types.
Source§

impl Serialize for Histogram

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T