Skip to main content

Module livemetrics

Module livemetrics 

Source
Available on crate features cli-progress or cli-tui only.
Expand description

Shared live-view metrics plumbing (recorder install + Prometheus-text sampler), compiled when either live-view feature is on. Shared live-metrics plumbing for faucet run — the in-process Prometheus recorder installer plus a pure Prometheus-text parser/aggregator.

Both the full-screen TUI (--tui, cli-tui) and the lightweight inline progress line (cli-progress) sample the same in-process Prometheus recorder’s rendered text a few times a second (read-only — zero hot-path impact) and reduce the handful of faucet_* series they care about into a TuiModel per tick. Everything below the recorder installer is pure and unit-tested; the render loops just call Sampler::observe with the rendered text.

This module is compiled whenever either live-view feature is on, so the recorder + parser are shared rather than duplicated.

Structs§

RowStats
Live view of one matrix row / invocation.
Sample
One parsed sample line: name{label="v",…} 1.5.
Sampler
Turns successive Prometheus renders into TuiModels, computing records/s from consecutive sink-records totals.
TuiModel
The reduced model the renderers draw.

Functions§

install_metrics_recorder
Install the Prometheus recorder for a live-view session and return its render handle. When the config carries an observability.prometheus block the /metrics HTTP endpoint is preserved (recorder + listener, exactly what install_observability would have set up); otherwise a listener-less recorder is installed purely as the live view’s data source. Idempotent: a second call returns the first call’s handle.
parse_samples
Parse the Prometheus text exposition format, skipping # HELP / # TYPE comments and lines that don’t parse (robustness over strictness — a live view must never crash on exporter output).
setup_observability
Install a live-view session’s observability: the CLI owns the metrics recorder (keeping the /metrics endpoint when one is configured) so it can render the recorder’s output; the rest of the observability config (OTLP traces) installs as usual with the prometheus block taken out.