Skip to main content

Module metrics_exporter

Module metrics_exporter 

Source
Expand description

Phase-C4: Prometheus / OpenMetrics exposition of live engine state.

This module emits the OpenMetrics 1.0 text format a Prometheus scraper will happily consume. It is intentionally a pure function over the in-memory episode list and (optionally) the streaming ingestor’s counters — no HTTP, no async runtime, no hyper / axum / tokio dependency. The operator runbook (§Phase-C6 README) documents three wiring options that cost less than 100 lines each: plain std::net::TcpListener loop, tiny_http crate, or a sidecar textfile collector read by node_exporter.

Metric catalogue (the names follow the Prometheus NAMESPACE_SUBSYSTEM_UNIT convention):

  • dsfb_episodes_total{motif="..."} — counter, total episodes emitted per motif class since process start.
  • dsfb_episode_peak_last{motif="..."} — gauge, |peak| of the most recently closed episode per motif. NaN when no episode has closed yet.
  • dsfb_episode_trust_sum_last{motif="..."} — gauge, trust-sum observed at the most recent episode boundary. Should stay in [0.99, 1.01]; deviations indicate an observer bug.
  • dsfb_streaming_residuals_staged — gauge, current reorder buffer occupancy.
  • dsfb_streaming_residuals_flushed_total — counter, samples moved from the reorder buffer into the canonical stream.
  • dsfb_streaming_residuals_dropped_out_of_window_total — counter, samples dropped because they arrived more than one reorder-window behind the flushed frontier. A non-zero value is an alertable condition (telemetry-pipeline is worse than the configured window).

The text format is deterministic given the same inputs — helpful for unit-testing and for diffing scrapes across deploys.

Structs§

MetricsSnapshot
Snapshot of counters an exporter can publish directly. Constructed from an Episode slice (typically the output of one MotifEngine::run or the accumulated set of closed episodes in a long-running daemon).

Functions§

render_openmetrics
Render a MetricsSnapshot as OpenMetrics 1.0 text. The output ends with # EOF\n as required by the OpenMetrics spec. The function is deterministic: same input → byte-identical output.