pub struct SampledTimer { /* private fields */ }Expand description
Counts every timed operation and samples elapsed latency into a histogram.
Durations are recorded in nanoseconds.
Implementations§
Source§impl SampledTimer
impl SampledTimer
Sourcepub fn new(bounds_nanos: &[u64], shard_count: usize, sample_stride: u64) -> Self
pub fn new(bounds_nanos: &[u64], shard_count: usize, sample_stride: u64) -> Self
Create a sampled timer with custom histogram bounds in nanoseconds.
sample_stride is rounded up to a power of two. A stride of 1 records
every call.
Sourcepub fn with_latency_buckets(shard_count: usize, sample_stride: u64) -> Self
pub fn with_latency_buckets(shard_count: usize, sample_stride: u64) -> Self
Create a sampled timer with default latency buckets in nanoseconds.
Sourcepub fn start(&self) -> SampledTimerGuard<'_>
pub fn start(&self) -> SampledTimerGuard<'_>
Start timing one operation.
Sourcepub fn record_elapsed(&self, elapsed: Duration)
pub fn record_elapsed(&self, elapsed: Duration)
Record an already-measured duration if this call should be sampled.
Sourcepub fn sample_count(&self) -> u64
pub fn sample_count(&self) -> u64
Number of latency samples recorded.
Sourcepub fn sample_sum_nanos(&self) -> u64
pub fn sample_sum_nanos(&self) -> u64
Sum of sampled latency values in nanoseconds.
Sourcepub fn avg_sample_nanos(&self) -> Option<f64>
pub fn avg_sample_nanos(&self) -> Option<f64>
Average sampled latency in nanoseconds.
Sourcepub fn calls_metric(&self) -> &Counter
pub fn calls_metric(&self) -> &Counter
Access the underlying call counter for export.
Trait Implementations§
Source§impl ClickHouseExport for SampledTimer
impl ClickHouseExport for SampledTimer
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for SampledTimer
impl DogStatsDExport for SampledTimer
Source§impl OtlpExport for SampledTimer
impl OtlpExport for SampledTimer
Source§impl PrometheusExport for SampledTimer
impl PrometheusExport for SampledTimer
Auto Trait Implementations§
impl Freeze for SampledTimer
impl RefUnwindSafe for SampledTimer
impl Send for SampledTimer
impl Sync for SampledTimer
impl Unpin for SampledTimer
impl UnsafeUnpin for SampledTimer
impl UnwindSafe for SampledTimer
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> 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>
Wrap the input message
T in a tonic::Request