Add metric declaration storage and validation to engine index (ticket 002)

Adds IndexKey::MetricDeclaration handling: DeclareMetric/RemoveMetricDeclaration
engine messages and a MetricDeclarations query, mirroring the pattern from ticket
001's param declarations. Params are derived from inline named capture groups on
the metric's own regex for v1 (referencing existing ParamDeclarations is left for
a future ticket). Validates the regex and every RegexToMetricPrimitiveMatcher's
capture-group reference at declaration time, reporting all bad matchers at once.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 12:49:29 +01:00
co-authored by Claude Sonnet 5
parent faca2af328
commit d37c35772d
2 changed files with 217 additions and 3 deletions
+8 -1
View File
@@ -1,4 +1,4 @@
use crate::data_value::MetricPrimitiveKind;
use crate::data_value::{MetricPrimitiveKind, RegexToMetricPrimitiveMatcher};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]
@@ -16,6 +16,13 @@ pub struct ParamDeclarationDto {
pub kind: MetricPrimitiveKind,
}
#[derive(Debug, Clone, Serialize)]
pub struct MetricDeclarationDto {
pub name: String,
pub message_match_regex: String,
pub params: Vec<RegexToMetricPrimitiveMatcher>,
}
#[derive(Debug, Clone, Serialize)]
pub struct TimelineBucketDto {
pub start_ms: i64,