pub struct DynamicHistogram { /* private fields */ }Expand description
Histogram keyed by runtime label sets.
Uses sharded index for key->series lookup and per-series sharded counters for fast updates.
Implementations§
Source§impl DynamicHistogram
impl DynamicHistogram
Sourcepub fn new(bounds: &[u64], shard_count: usize) -> Self
pub fn new(bounds: &[u64], shard_count: usize) -> Self
Creates a new runtime-labeled histogram with given bucket boundaries.
Sourcepub fn with_limits(
bounds: &[u64],
shard_count: usize,
max_series: usize,
) -> Self
pub fn with_limits( bounds: &[u64], shard_count: usize, max_series: usize, ) -> Self
Creates a new runtime-labeled histogram 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 with_latency_buckets(shard_count: usize) -> Self
pub fn with_latency_buckets(shard_count: usize) -> Self
Creates a histogram with default latency buckets (in microseconds).
Sourcepub fn series(&self, labels: &[(&str, &str)]) -> DynamicHistogramSeries
pub fn series(&self, labels: &[(&str, &str)]) -> DynamicHistogramSeries
Resolve a reusable series handle for labels.
Preferred for hot paths when labels come from a finite active set.
Sourcepub fn record(&self, labels: &[(&str, &str)], value: u64)
pub fn record(&self, labels: &[(&str, &str)], value: u64)
Record a value for the series identified by labels.
Sourcepub fn buckets_cumulative(&self, labels: &[(&str, &str)]) -> Vec<(u64, u64)>
pub fn buckets_cumulative(&self, labels: &[(&str, &str)]) -> Vec<(u64, u64)>
Get cumulative bucket counts for the series identified by labels.
Sourcepub fn count(&self, labels: &[(&str, &str)]) -> u64
pub fn count(&self, labels: &[(&str, &str)]) -> u64
Get count for the series identified by labels.
Sourcepub fn snapshot(&self) -> Vec<(DynamicLabelSet, Vec<(u64, u64)>, u64, u64)>
pub fn snapshot(&self) -> Vec<(DynamicLabelSet, Vec<(u64, u64)>, u64, u64)>
Returns a snapshot of all label-set with their histogram data.
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 DynamicHistogramSeries handle to them.
Returns the number of series evicted.
Trait Implementations§
Source§impl ClickHouseExport for DynamicHistogram
impl ClickHouseExport for DynamicHistogram
fn export_clickhouse( &self, batch: &mut ClickHouseMetricBatch, name: &str, description: &str, time_unix_nano: u64, )
Source§impl DogStatsDExport for DynamicHistogram
impl DogStatsDExport for DynamicHistogram
Source§impl OtlpExport for DynamicHistogram
impl OtlpExport for DynamicHistogram
Source§impl PrometheusExport for DynamicHistogram
impl PrometheusExport for DynamicHistogram
Auto Trait Implementations§
impl !Freeze for DynamicHistogram
impl !RefUnwindSafe for DynamicHistogram
impl Send for DynamicHistogram
impl Sync for DynamicHistogram
impl Unpin for DynamicHistogram
impl UnsafeUnpin for DynamicHistogram
impl UnwindSafe for DynamicHistogram
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