Expand description
Metrics collection and reporting.
This module provides metrics collection for monitoring session performance and behavior. It includes:
- Core metrics (counters, gauges, histograms)
- OpenTelemetry span integration (with
metricsfeature) - Prometheus export (with
metricsfeature)
§Basic Usage
use rust_expect::metrics::{Counter, Gauge, Timer, SessionMetrics};
// Use basic metrics
let counter = Counter::new();
counter.inc();
let gauge = Gauge::new();
gauge.set(42);
// Time an operation
let timer = Timer::start();
// ... do work ...
let elapsed = timer.stop();§OpenTelemetry Integration (with metrics feature)
ⓘ
use rust_expect::metrics::otel::{init_tracing, shutdown_tracing};
// Initialize OpenTelemetry tracing
init_tracing("my-service", "http://localhost:4317")?;
// Your application code with tracing spans...
// Clean shutdown
shutdown_tracing();Structs§
- Counter
- A counter metric.
- Gauge
- A gauge metric.
- Histogram
- A histogram for measuring distributions.
- Metrics
Registry - Global metrics registry.
- Metrics
Snapshot - Snapshot of metrics.
- Session
Metrics - Session metrics.
- Timer
- Timer for measuring durations.