parse_metrics

Function parse_metrics 

Source
pub fn parse_metrics(spec: &str) -> Result<Vec<&'static str>>
Expand description

Parse a CLI --metrics spec into a typed Vec<&'static str> of registry names. Format: comma-separated names that must each match a name field from either CTPROF_METRICS or CTPROF_DERIVED_METRICS. Whitespace around each name is trimmed. Empty input parses to an empty Vec — caller treats that as “every metric renders” via DisplayOptions::is_metric_enabled, mirroring parse_sections’s empty-input semantic.

The returned &'static strs point into the registry’s own name fields (not into the input spec), so the parsed vector survives the input string going out of scope and equality checks against registry names are pointer-stable.

Errors (mirrored from parse_sections / parse_columns so the three CLI surfaces report drift identically):

  • Unknown name (cite the offending token).
  • Duplicate name across two entries.
  • Empty token between commas.