pub struct Histogram { /* private fields */ }Expand description
Open Metrics Histogram to measure distributions of discrete events.
let histogram = Histogram::new(exponential_buckets(1.0, 2.0, 10));
histogram.observe(4.2);Histogram does not implement Default, given that the choice of
bucket values depends on the situation Histogram is used in. As an
example, to measure HTTP request latency, the values suggested in the
Golang implementation might work for you:
// Default values from go client(https://github.com/prometheus/client_golang/blob/5d584e2717ef525673736d72cd1d12e304f243d7/prometheus/histogram.go#L68)
let custom_buckets = [
0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0,
];
let histogram = Histogram::new(custom_buckets);
histogram.observe(4.2);Implementations§
Source§impl Histogram
impl Histogram
Sourcepub fn new(buckets: impl IntoIterator<Item = f64>) -> Histogram
pub fn new(buckets: impl IntoIterator<Item = f64>) -> Histogram
Create a new Histogram.
let histogram = Histogram::new([10.0, 100.0, 1_000.0]);Sourcepub fn new_native(native: NativeHistogramConfig) -> Histogram
pub fn new_native(native: NativeHistogramConfig) -> Histogram
Create a new native Histogram without classic buckets.
Native-only histograms can only be encoded by the Prometheus protobuf encoder. Text and OpenMetrics protobuf encoders do not have native histogram fields and reject native-only histograms.
Sourcepub fn new_classic_and_native(
buckets: impl IntoIterator<Item = f64>,
native: NativeHistogramConfig,
) -> Histogram
pub fn new_classic_and_native( buckets: impl IntoIterator<Item = f64>, native: NativeHistogramConfig, ) -> Histogram
Create a new Histogram with both classic and native buckets.
Prometheus protobuf encodes both representations in one histogram message. Encoders without native histogram support encode the classic buckets.
Trait Implementations§
Source§impl EncodeMetric for Histogram
impl EncodeMetric for Histogram
Source§impl HistogramExt for Histogram
impl HistogramExt for Histogram
Source§fn observe_between(&self, start: SystemTime, end: SystemTime)
fn observe_between(&self, start: SystemTime, end: SystemTime)
Source§impl TypedMetric for Histogram
impl TypedMetric for Histogram
Source§const TYPE: MetricType = MetricType::Histogram
const TYPE: MetricType = MetricType::Histogram
Auto Trait Implementations§
impl !RefUnwindSafe for Histogram
impl !UnwindSafe for Histogram
impl Freeze for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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