pub struct MaxGauge { /* private fields */ }Expand description
A thread-sharded maximum tracker exported as a gauge.
This is useful for recording peaks such as maximum queue depth or the highest number of in-flight requests seen during an export interval.
Unlike crate::Gauge, this is not a point-in-time set() value.
Writers call observe, and readers aggregate by taking
the maximum across shards.
Implementations§
Source§impl MaxGauge
impl MaxGauge
Sourcepub fn new(shard_count: usize) -> Self
pub fn new(shard_count: usize) -> Self
Create a new max gauge with all shards initialized to zero.
This is appropriate for metrics that are naturally non-negative.
Sourcepub fn with_value(shard_count: usize, initial: i64) -> Self
pub fn with_value(shard_count: usize, initial: i64) -> Self
Create a new max gauge with all shards initialized to initial.
Sourcepub fn reset(&self)
pub fn reset(&self)
Reset all shards to the original value configured at construction.
This is intended for export/sampling code, not the hot path.
Sourcepub fn swap_reset(&self) -> i64
pub fn swap_reset(&self) -> i64
Reset all shards and return the previous maximum.
Concurrent observations that land on already-reset shards may be
attributed to the next window rather than the current one. No maxima
are lost, but timing near the reset boundary is eventually consistent
in the same way as crate::Counter::swap.
Trait Implementations§
Source§impl ClickHouseExport for MaxGauge
impl ClickHouseExport for MaxGauge
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for MaxGauge
impl DogStatsDExport for MaxGauge
Source§impl OtlpExport for MaxGauge
impl OtlpExport for MaxGauge
Auto Trait Implementations§
impl Freeze for MaxGauge
impl RefUnwindSafe for MaxGauge
impl Send for MaxGauge
impl Sync for MaxGauge
impl Unpin for MaxGauge
impl UnsafeUnpin for MaxGauge
impl UnwindSafe for MaxGauge
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