Expand description
SZ-ORM Observability Module
Provides Prometheus exporter, SLO burn rate monitoring, and other capabilities.
OTLP export is provided by the otlp feature of sz-orm-tracing (this module does not include OTLP).
§Core Capabilities
§1. MetricsRegistry (enabled by default)
Unified metric registry, supporting Counter / Gauge / Histogram types,
with built-in thread safety (RwLock), and can output Prometheus text format via render().
§2. Prometheus exporter
Exposes the /metrics HTTP endpoint on the specified port via start_metrics_server,
for Prometheus to scrape. Implemented based on tokio::net::TcpListener (does not depend on hyper).
§3. SLO burn rate
Computes SLO burn rate based on 5m / 1h windows, supporting multi-window alerts.
§Quick Start
use sz_orm_observability::{MetricsRegistry, MetricKind};
use std::time::Duration;
// Create metric registry
let registry = MetricsRegistry::new();
// Register metrics
let counter = registry.register_counter("sz_orm_pool_acquires_total", "Total pool acquire calls");
let gauge = registry.register_gauge("sz_orm_pool_active_connections", "Current active connections");
let histogram = registry.register_histogram(
"sz_orm_query_duration_seconds",
"Query duration in seconds",
vec![0.001, 0.01, 0.1, 1.0, 10.0],
);
// Update metrics
counter.inc();
gauge.set(5.0);
histogram.observe(0.025);
// Output Prometheus text format
let output = registry.render();
println!("{}", output);Re-exports§
pub use slo::SloBurnRate;pub use slo::SloConfig;pub use slo::SloMonitor;pub use summary::LabeledHistogram;pub use summary::PushSnapshot;pub use summary::PushgatewayConfig;pub use summary::PushgatewayExporter;pub use summary::Summary;
Modules§
Structs§
- Counter
- Counter (monotonically increasing)
- Gauge
- Gauge (can increase or decrease)
- Histogram
- Histogram (latency distribution, etc.)
- Metric
Meta - Metric metadata
- Metrics
Registry - Metric registry
Enums§
- Metric
Kind - Metric type
Functions§
- start_
metrics_ server - Start the Prometheus metrics HTTP server