Skip to main content

Module metrics

Module metrics 

Source
Expand description

Prometheus metrics (B1). OPEN baseline (BOUNDARY.md §1.6).

Hand-rolled on purpose: the model is fixed-bucket histograms + _sum/_count with NO in-process quantiles — Prometheus computes them at scrape time via histogram_quantile(). That keeps the whole thing ~N AtomicU64 + a trivial text serializer, not worth a dep tree.

The metric NAMES and label VALUES are ABI (a renamed metric breaks every downstream Grafana query). decision is a CLOSED, low-cardinality set; never put user-derived data (path, IP, rule_id) in a label — that is the classic cardinality-explosion footgun.

Instrumentation is a pure side effect: every counter is AtomicU64 with Relaxed ordering, no lock or .await on the hot path, so recording can never change a verdict nor perturb the latency it measures. The Metrics type is exporter-neutral; Metrics::render is the Prometheus exporter (the only Prometheus-specific piece). A future OTLP sink would be a second renderer, not a rewrite.

Structs§

Metrics
Process-lifetime metrics registry. Shared via Arc; lives in StaticState so it survives config reloads (like the rate-limit store).

Enums§

Outcome
Final disposition of a request — the closed value set of the decision label. Discriminants are the array index into the counters; keep Outcome::ALL in sync.