Add Metrics API: declare/list params and metrics, query bucket values (ticket 004)
Exposes param/metric declarations and derived bucket data over HTTP: POST /api/params and POST /api/metrics validate and declare against the engine, persisting into the active profile (if any) so declarations survive a restart; GET /api/metrics lists declarations; GET /api/metrics/:name queries bucket values with label, time-range, sequence, and limit filters. Adds a new EngineQuery::BucketValues variant that layers this filtering on top of ticket 003's bucket_values helper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
f0348589f5
commit
49e8590cf3
@@ -1,6 +1,7 @@
|
||||
use crate::timestamp::Timestamp;
|
||||
use serde::Serialize;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
|
||||
/// A simple, self-describing value used by metrics/labels without pulling in JSON.
|
||||
#[allow(dead_code)]
|
||||
@@ -42,6 +43,21 @@ impl Ord for MetricPrimitive {
|
||||
}
|
||||
}
|
||||
|
||||
/// Textual form used for label-filter comparisons over the metrics API
|
||||
/// (`GET /api/metrics/:name?labels=foo=bar`): query-string values are plain
|
||||
/// strings, so a label filter is compared against this formatted form rather
|
||||
/// than trying to parse the filter value into a typed `MetricPrimitive`.
|
||||
impl fmt::Display for MetricPrimitive {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
MetricPrimitive::String(s) => write!(f, "{s}"),
|
||||
MetricPrimitive::Number(Number::Int(n)) => write!(f, "{n}"),
|
||||
MetricPrimitive::Number(Number::Float(n)) => write!(f, "{n}"),
|
||||
MetricPrimitive::Timestamp(ts) => write!(f, "{}", ts.as_millis()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Numbers are kept as a tagged int/float pair so exact integers stay exact.
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Copy, Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user