fix: align compaction metric schema

This commit is contained in:
2026-09-16 06:24:45 +09:00
parent fef3b6f4a0
commit b6960878a6
5 changed files with 74 additions and 54 deletions
+10 -5
View File
@@ -4,9 +4,9 @@ Session 単位の append-only な観測値を既存 session-log に記録し、
metrics 読取 / JSONL export 経路で取り出すための小さなヘルパークレートです。
- 保存先は `session-store` の `LogEntry::Extension`
- domain は `session.metrics`
- extension domain は `metrics`
- metric は `name / ts / dimensions / value / correlation_id` の最小 envelope
- `record_metric` / `record_metric_at` で現在の Segment に append する
- `record_metric` で指定した Session / Segment に append する
- `read_segment_metrics` は 1 Segment、`read_session_metrics` は Session 内の全
Segment を読み、各 metric に `segment_id` と `compacted_from` を付ける
- `export_metrics_jsonl` はその located metric を newline-delimited JSON にする
@@ -19,14 +19,19 @@ request を結合できる。
```rust,ignore
use session_metrics::{
Metric, export_metrics_jsonl, read_session_metrics, record_metric_at,
Metric, export_metrics_jsonl, read_session_metrics, record_metric,
};
let metric = Metric::now("compact.start")
.with_value(12_345.0)
.with_dimension("mode", "automatic")
.with_dimension("trigger", "automatic")
.with_correlation_id("018f6f8a-9822-7b11-8b35-706f30313700");
record_metric_at(&store, location, &metric)?;
record_metric(
&store,
location.session_id,
location.segment_id,
&metric,
)?;
let records = read_session_metrics(&store, location.session_id)?;
let jsonl = export_metrics_jsonl(&records)?;