pub struct Histogram { /* private fields */ }Expand description
A fixed-bucket histogram with thread-sharded counters.
Buckets are defined by upper bounds (inclusive). Values are placed in the first bucket whose bound is >= the value. Values exceeding all bounds go in the final “+Inf” bucket.
Implementations§
Source§impl Histogram
impl Histogram
Sourcepub fn new(bounds: &[u64], shard_count: usize) -> Self
pub fn new(bounds: &[u64], shard_count: usize) -> Self
Create a histogram with the given bucket boundaries.
Boundaries should be sorted ascending. Each boundary represents the upper bound (inclusive) of a bucket. An implicit +Inf bucket is added.
shard_count is passed to each underlying Counter.
Sourcepub fn with_latency_buckets(shard_count: usize) -> Self
pub fn with_latency_buckets(shard_count: usize) -> Self
Create a histogram with default latency buckets (in microseconds).
Buckets: 10µs, 50µs, 100µs, 500µs, 1ms, 5ms, 10ms, 50ms, 100ms, 500ms, 1s, 5s, 10s
Sourcepub fn buckets_cumulative(&self) -> Vec<(u64, u64)>
pub fn buckets_cumulative(&self) -> Vec<(u64, u64)>
Get cumulative bucket counts – for Prometheus exposition.
Returns pairs of (upper_bound, cumulative_count). The last entry
has bound u64::MAX representing +Inf.
Prefer Self::buckets_cumulative_iter on the export path; it avoids
the Vec allocation per call.
Sourcepub fn buckets_cumulative_iter(&self) -> impl Iterator<Item = (u64, u64)> + '_
pub fn buckets_cumulative_iter(&self) -> impl Iterator<Item = (u64, u64)> + '_
Iterator form of Self::buckets_cumulative that skips the Vec
allocation. Used by the Prometheus and OTLP export paths.
pub fn sum(&self) -> u64
pub fn count(&self) -> u64
Trait Implementations§
Source§impl ClickHouseExport for Histogram
impl ClickHouseExport for Histogram
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for Histogram
impl DogStatsDExport for Histogram
Source§impl HistogramSnapshot for Histogram
impl HistogramSnapshot for Histogram
Source§impl OtlpExport for Histogram
impl OtlpExport for Histogram
Auto Trait Implementations§
impl Freeze for Histogram
impl RefUnwindSafe for Histogram
impl Send for Histogram
impl Sync for Histogram
impl Unpin for Histogram
impl UnsafeUnpin 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
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>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request