pub struct TimingHistogram { /* private fields */ }Expand description
A histogram for collecting timing distributions.
This provides Prometheus-style histogram buckets for aggregating timing data across many requests.
§Example
ⓘ
let mut histogram = TimingHistogram::with_buckets(vec![
1.0, 5.0, 10.0, 25.0, 50.0, 100.0, 250.0, 500.0, 1000.0
]);
histogram.observe(42.5); // 42.5ms response time
histogram.observe(150.0);
let buckets = histogram.buckets();
let avg = histogram.mean();Implementations§
Source§impl TimingHistogram
impl TimingHistogram
Sourcepub fn with_buckets(bucket_bounds: Vec<f64>) -> Self
pub fn with_buckets(bucket_bounds: Vec<f64>) -> Self
Create a histogram with the given bucket upper bounds.
Bounds should be sorted in ascending order.
Sourcepub fn http_latency() -> Self
pub fn http_latency() -> Self
Create a histogram with default HTTP latency buckets.
Buckets: 1ms, 5ms, 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s
Sourcepub fn buckets(&self) -> Vec<TimingHistogramBucket>
pub fn buckets(&self) -> Vec<TimingHistogramBucket>
Get the bucket data.
Trait Implementations§
Source§impl Clone for TimingHistogram
impl Clone for TimingHistogram
Source§fn clone(&self) -> TimingHistogram
fn clone(&self) -> TimingHistogram
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TimingHistogram
impl Debug for TimingHistogram
Auto Trait Implementations§
impl Freeze for TimingHistogram
impl RefUnwindSafe for TimingHistogram
impl Send for TimingHistogram
impl Sync for TimingHistogram
impl Unpin for TimingHistogram
impl UnwindSafe for TimingHistogram
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).