Expand description
Fast, thread-sharded counters and histograms for high-performance telemetry.
OpenTelemetry counters use atomic operations with global synchronization, which causes cache-line bouncing across cores. This crate provides thread-local sharded counters that:
- Increment with no cross-thread contention (just a thread-local write)
- Are cache-line padded to avoid false sharing (using crossbeam’s CachePadded)
- Aggregate on read (sum all shards)
§Labeled Metrics
For dimensional metrics (counters/gauges/histograms broken down by label),
use the Labeled* types with a LabelEnum implementation. These provide
O(1) lookup via array indexing instead of HashMap lookups.
ⓘ
use fast_telemetry::{LabeledCounter, LabelEnum};
#[derive(Copy, Clone, Debug)]
enum HttpMethod { Get, Post, Put, Delete }
impl LabelEnum for HttpMethod { /* ... */ }
let counter: LabeledCounter<HttpMethod> = LabeledCounter::new(4);
counter.inc(HttpMethod::Get); // O(1) array index, no hashingRe-exports§
pub use span::CompletedSpan;pub use span::Span;pub use span::SpanAttribute;pub use span::SpanCollector;pub use span::SpanEvent;pub use span::SpanId;pub use span::SpanKind;pub use span::SpanStatus;pub use span::SpanValue;pub use span::TraceId;pub use span::current_span_id;pub use span::current_trace_id;
Modules§
- clickhouse
- otlp
- span
- Standalone distributed tracing for fast-telemetry.
Structs§
- Click
House Metric Batch - OTel-standard ClickHouse rows built directly from fast-telemetry primitives.
- Counter
- A sharded atomic counter.
- Distribution
- Exponential histogram distribution for high-performance metric recording.
- Dynamic
Counter - Counter keyed by runtime label sets.
- Dynamic
Counter Series - A reusable handle to a dynamic-label counter series.
- Dynamic
Distribution - Distribution keyed by runtime label sets.
- Dynamic
Distribution Series - A reusable handle to a dynamic-label distribution series.
- Dynamic
Gauge - Gauge keyed by runtime label sets.
- Dynamic
Gauge I64 - Signed integer gauge keyed by runtime label sets.
- Dynamic
Gauge I64Series - A reusable handle to a dynamic-label i64 gauge series.
- Dynamic
Gauge Series - A reusable handle to a dynamic-label gauge series.
- Dynamic
Histogram - Histogram keyed by runtime label sets.
- Dynamic
Histogram Series - A reusable handle to a dynamic-label histogram series.
- Dynamic
Label Set - Canonicalized runtime label set.
- Gauge
- A cache-padded atomic gauge for point-in-time measurements.
- Gauge
F64 - A cache-padded atomic gauge for floating-point point-in-time measurements.
- Histogram
- A fixed-bucket histogram with thread-sharded counters.
- Labeled
Counter - A counter indexed by an enum label, providing O(1) dimensional metrics.
- Labeled
Gauge - A gauge indexed by an enum label, providing O(1) dimensional metrics.
- Labeled
Histogram - A histogram indexed by an enum label, providing O(1) dimensional metrics.
- Labeled
Sampled Timer - Label-indexed sampled timer with O(1) lookup.
- MaxGauge
- A thread-sharded maximum tracker exported as a gauge.
- MaxGauge
F64 - A thread-sharded maximum tracker for floating-point values.
- Metric
Label - One borrowed metric label pair.
- Metric
Labels - Borrowed labels for one metric observation.
- Metric
Labels Iter - Iterator over borrowed metric labels.
- Metric
Meta - Immutable metadata for one metric observation.
- MinGauge
- A thread-sharded minimum tracker exported as a gauge.
- MinGauge
F64 - A thread-sharded minimum tracker for floating-point values.
- Sampled
Timer - Counts every timed operation and samples elapsed latency into a histogram.
- Sampled
Timer Guard - RAII guard returned by
SampledTimer::startandLabeledSampledTimer::start.
Enums§
- Metric
Kind - Coarse semantic kind for a metric observation.
- Temporality
- Aggregation temporality used during export.
Traits§
- Click
House Export - Direct ClickHouse export trait for metric primitives.
- Distribution
Snapshot - Borrowed snapshot view for exponential-bucket distributions.
- DogStatsD
Export - Trait for exporting a metric in DogStatsD format.
- Histogram
Snapshot - Borrowed snapshot view for fixed-bucket histograms.
- Label
Enum - Trait for label enums used with
LabeledCounter,LabeledGauge, etc. - Metric
Visitor - Visitor for structured cumulative metric observations.
- Otlp
Export - Trait for exporting a metric as OTLP protobuf
Metricmessages. - Prometheus
Export - Trait for exporting a metric in Prometheus text exposition format.
Functions§
- advance_
cycle - Advance the eviction cycle by 1 and return the new value.
- current_
cycle - Get the current eviction cycle.
Derive Macros§
- Derive
Label - Derive macro for implementing
LabelEnumon enums. - Export
Metrics - Derive macro for exporting metrics in Prometheus, DogStatsD, and OTLP formats.