Struct HistogramBuilder
#[non_exhaustive]pub struct HistogramBuilder<'a, T> {
pub instrument_provider: &'a dyn InstrumentProvider,
pub name: Cow<'static, str>,
pub description: Option<Cow<'static, str>>,
pub unit: Option<Cow<'static, str>>,
pub boundaries: Option<Vec<f64>>,
/* private fields */
}
Expand description
Configuration for building a Histogram.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.instrument_provider: &'a dyn InstrumentProvider
Instrument provider is used to create the instrument.
name: Cow<'static, str>
Name of the Histogram.
description: Option<Cow<'static, str>>
Description of the Histogram.
unit: Option<Cow<'static, str>>
Unit of the Histogram.
boundaries: Option<Vec<f64>>
Bucket boundaries for the histogram.
Implementations§
§impl<'a, T> HistogramBuilder<'a, T>
impl<'a, T> HistogramBuilder<'a, T>
pub fn with_description<S>(self, description: S) -> HistogramBuilder<'a, T>
pub fn with_description<S>(self, description: S) -> HistogramBuilder<'a, T>
Set the description for this instrument
pub fn with_unit<S>(self, unit: S) -> HistogramBuilder<'a, T>
pub fn with_unit<S>(self, unit: S) -> HistogramBuilder<'a, T>
Set the unit for this instrument.
Unit is case sensitive(kb
is not the same as kB
).
Unit must be:
- ASCII string
- No longer than 63 characters
pub fn with_boundaries(self, boundaries: Vec<f64>) -> HistogramBuilder<'a, T>
pub fn with_boundaries(self, boundaries: Vec<f64>) -> HistogramBuilder<'a, T>
Set the boundaries for this histogram.
Setting boundaries is optional. By default, the boundaries are set to:
[0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 7500.0, 10000.0]
§Notes
- Boundaries must not contain
f64::NAN
,f64::INFINITY
orf64::NEG_INFINITY
- Values must be in strictly increasing order (e.g., each value must be greater than the previous).
- Boundaries must not contain duplicate values.
If invalid boundaries are provided, the instrument will not report
measurements.
Providing an empty vec![]
means no bucket information will be
calculated.
§Warning
Using more buckets can improve the accuracy of percentile calculations in backends. However, this comes at a cost, including increased memory, CPU, and network usage. Choose the number of buckets carefully, considering your application’s performance and resource requirements.
§impl HistogramBuilder<'_, Histogram<f64>>
impl HistogramBuilder<'_, Histogram<f64>>
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for HistogramBuilder<'a, T>
impl<'a, T> !RefUnwindSafe for HistogramBuilder<'a, T>
impl<'a, T> !Send for HistogramBuilder<'a, T>
impl<'a, T> !Sync for HistogramBuilder<'a, T>
impl<'a, T> Unpin for HistogramBuilder<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for HistogramBuilder<'a, T>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more