pub struct DynamicGaugeI64 { /* private fields */ }Expand description
Signed integer gauge keyed by runtime label sets.
Unlike DynamicCounter, this exports as a gauge (absolute value) rather than
a counter (delta). Use for metrics like “active connections” that go up and down.
Uses sharded atomics internally for fast concurrent updates.
Implementations§
Source§impl DynamicGaugeI64
impl DynamicGaugeI64
Sourcepub fn with_max_series(shard_count: usize, max_series: usize) -> Self
pub fn with_max_series(shard_count: usize, max_series: usize) -> Self
Creates a new runtime-labeled i64 gauge with a series cardinality cap.
When the number of unique label sets approximately reaches max_series,
new label sets are redirected into a single overflow series
(__ft_overflow=true). The cap is checked via a lock-free atomic counter,
so concurrent inserts may briefly overshoot by the number of in-flight
writers before the overflow kicks in.
Sourcepub fn series(&self, labels: &[(&str, &str)]) -> DynamicGaugeI64Series
pub fn series(&self, labels: &[(&str, &str)]) -> DynamicGaugeI64Series
Resolve a reusable series handle for labels.
Sourcepub fn add(&self, labels: &[(&str, &str)], value: i64)
pub fn add(&self, labels: &[(&str, &str)], value: i64)
Adds value to the gauge identified by labels (can be negative).
Sourcepub fn set(&self, labels: &[(&str, &str)], value: i64)
pub fn set(&self, labels: &[(&str, &str)], value: i64)
Sets the gauge identified by labels to an absolute value.
Sourcepub fn get(&self, labels: &[(&str, &str)]) -> i64
pub fn get(&self, labels: &[(&str, &str)]) -> i64
Gets the current value for the gauge identified by labels.
Sourcepub fn snapshot(&self) -> Vec<(DynamicLabelSet, i64)>
pub fn snapshot(&self) -> Vec<(DynamicLabelSet, i64)>
Returns a snapshot of all label-set/value pairs.
Sourcepub fn cardinality(&self) -> usize
pub fn cardinality(&self) -> usize
Returns the current number of distinct label sets.
Sourcepub fn overflow_count(&self) -> u64
pub fn overflow_count(&self) -> u64
Returns the number of records routed to the overflow bucket.
A non-zero value indicates the cardinality cap was hit and label fidelity is being lost. Use this to alert on cardinality pressure.
Sourcepub fn evict_stale(&self, max_staleness: u32) -> usize
pub fn evict_stale(&self, max_staleness: u32) -> usize
Evict series that haven’t been accessed for max_staleness cycles.
Call this after advance_cycle() in your exporter task.
Series are marked as evicted (so cached handles see the tombstone),
then removed from the index.
Protected series (Arc::strong_count > 1) are never evicted - someone holds a DynamicGaugeI64Series handle to them.
Returns the number of series evicted.
Trait Implementations§
Source§impl ClickHouseExport for DynamicGaugeI64
impl ClickHouseExport for DynamicGaugeI64
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for DynamicGaugeI64
impl DogStatsDExport for DynamicGaugeI64
Source§impl OtlpExport for DynamicGaugeI64
impl OtlpExport for DynamicGaugeI64
Source§impl PrometheusExport for DynamicGaugeI64
impl PrometheusExport for DynamicGaugeI64
Auto Trait Implementations§
impl !Freeze for DynamicGaugeI64
impl !RefUnwindSafe for DynamicGaugeI64
impl Send for DynamicGaugeI64
impl Sync for DynamicGaugeI64
impl Unpin for DynamicGaugeI64
impl UnsafeUnpin for DynamicGaugeI64
impl UnwindSafe for DynamicGaugeI64
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