pub fn parse_thresholds(
json_or_yaml: &str,
) -> Result<Vec<Threshold>, ThresholdError>Expand description
Parses a list of thresholds from a JSON or YAML string.
The input must be an object with a "thresholds" key whose value is an
array of threshold objects:
{ "thresholds": [{ "metric": "latency_p99", "operator": "lt", "value": 200.0 }] }or equivalently in YAML:
thresholds:
- metric: latency_p99
operator: lt
value: 200.0JSON is attempted first; if that fails, YAML is attempted. If both fail,
the JSON error is returned wrapped in ThresholdError::ParseError.
Each threshold is then validated:
valuemust be finite- For
error_rate,valuemust be in [0.0, 1.0]