Files
ottyl/tickets/002-metric-declarations.md
T
2026-09-05 12:46:45 +01:00

1.6 KiB

002 — Metric declarations

Summary

Implement the MetricDeclaration slice of the index: a language/API for declaring a metric — a regex that matches a log message plus params extracted from it — so that matching logs can later be bucketed (003).

Scope

  • IndexKey::MetricDeclaration { name } paired with DataValue::MetricDeclaration (already sketched in data_value.rs: message_match_regex + Vec<RegexToMetricPrimitiveMatcher>).
  • Engine message(s) to add/list/remove a metric declaration.
  • A metric declaration's params may reference params already declared via 001 (e.g. label a bucket by an existing param) in addition to inline capture groups on the metric's own regex — decide and document which is supported for v1 (README implies inline capture-group derivation is the primary mechanism: "buckets and parameters can be derived" from the metric declaration itself).
  • Validate the regex and capture-group → primitive-kind mapping at declaration time, same as param declarations.

Acceptance criteria

  • Declaring a metric with a valid regex + param matchers succeeds and is retrievable.
  • Invalid regex, or a matcher referencing a capture group the regex doesn't have, is rejected at declaration time.
  • Declarations sit in their own contiguous range of the BTreeMap (MetricDeclaration between ParamMetricSplit and MetricBucketSplit).

Depends on