Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Telemetry primitives (plan #65).

Borrowed from MAX’s serve/telemetry/ module shape (counters, histograms, stopwatches) but stripped to a pure data layer. Today this is a single in-process MetricsRegistry; a future serving crate can route the registry to a sidecar process / Prometheus / OTel exporter without changing the call sites.

Why now (without a serving crate to consume it)?

  • Lets the autotuner / fusion passes record decisions while they’re being made, viewable later via [MetricsRegistry:: snapshot].
  • Establishes the “metrics live in their own type, not scattered through hot paths” pattern before we accumulate a hundred ad-hoc counters.

Structs§

Counter
Monotonic 64-bit counter. Cheap (atomic add); safe to call from any thread.
Histogram
Fixed-bucket exponential histogram — 16 buckets covering up to 2^16 ≈ 65k of the chosen unit. Right for ns-to-ms latency distributions or 1-100k sample-count distributions.
HistogramSnapshot
MetricsRegistry
Global registry of named counters and histograms. Indexed by static string keys; lookups are O(log N) on a BTreeMap. Lock is only held during register/lookup, not during increment.
Snapshot