pub struct DynamicGauge { /* private fields */ }Expand description
Gauge keyed by runtime label sets.
Uses sharded index for key->series lookup for concurrent access.
Implementations§
Source§impl DynamicGauge
impl DynamicGauge
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 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)]) -> DynamicGaugeSeries
pub fn series(&self, labels: &[(&str, &str)]) -> DynamicGaugeSeries
Resolve a reusable series handle for labels.
Preferred for hot paths when labels come from a finite active set.
Sourcepub fn set(&self, labels: &[(&str, &str)], value: f64)
pub fn set(&self, labels: &[(&str, &str)], value: f64)
Set the gauge value for the series identified by labels.
Sourcepub fn get(&self, labels: &[(&str, &str)]) -> f64
pub fn get(&self, labels: &[(&str, &str)]) -> f64
Get the current value for the series identified by labels.
Sourcepub fn snapshot(&self) -> Vec<(DynamicLabelSet, f64)>
pub fn snapshot(&self) -> Vec<(DynamicLabelSet, f64)>
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 DynamicGaugeSeries handle to them.
Returns the number of series evicted.
Trait Implementations§
Source§impl ClickHouseExport for DynamicGauge
impl ClickHouseExport for DynamicGauge
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for DynamicGauge
impl DogStatsDExport for DynamicGauge
Source§impl OtlpExport for DynamicGauge
impl OtlpExport for DynamicGauge
Source§impl PrometheusExport for DynamicGauge
impl PrometheusExport for DynamicGauge
Auto Trait Implementations§
impl !Freeze for DynamicGauge
impl !RefUnwindSafe for DynamicGauge
impl Send for DynamicGauge
impl Sync for DynamicGauge
impl Unpin for DynamicGauge
impl UnsafeUnpin for DynamicGauge
impl UnwindSafe for DynamicGauge
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