36 lines
1.6 KiB
Markdown
36 lines
1.6 KiB
Markdown
# 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](003-metric-bucket-derivation.md)).
|
|
|
|
## 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](001-param-declarations.md) (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
|
|
|
|
- [001 — Param declarations](001-param-declarations.md) (shares matcher/primitive
|
|
validation code and the "derive a value from a regex capture" concept).
|