pub fn extract_metrics(
output: &str,
format: &OutputFormat,
stream: MetricStream,
) -> Result<Vec<Metric>, String>Expand description
Extract metrics from a payload’s captured output per its declared
OutputFormat.
output carries whichever stream PayloadRun decided to extract
from — stdout on the happy path, stderr under the stdout-primary
stderr-fallback contract when stdout produced an empty result.
The extractor itself is stream-agnostic; it parses whatever byte
blob it is handed.
Returns an empty Vec for OutputFormat::ExitCode and for
OutputFormat::Json when no JSON document is located or the
document carries no numeric leaves. JSON-parse errors are
non-fatal: the extraction returns Vec::new() so downstream
MetricCheck evaluation reports each
referenced metric as missing rather than failing the whole run.
§Known truncation point: depth cap
The Json arm routes through walk_json_leaves, which enforces
a hard recursion cap of MAX_WALK_DEPTH (currently 64).
Subtrees past that depth are silently dropped from the metric
list — a tracing::warn! fires and a sentinel metric named
WALK_TRUNCATION_SENTINEL_NAME
(__walk_json_leaves_truncated) is appended to the return
value, with value set to the depth at which truncation
occurred. Callers that want to distinguish “no deep metrics”
from “deep metrics dropped by the cap” scan the returned Vec
for a metric with that name. Practical upper bound: 64 is well
below serde_json’s default parse recursion limit (128) and
covers every realistic payload schema observed in the crate
(fio maxes out around depth 8, schbench around depth 3).