Watch
0
0
Fork
You've already forked hyperhive
0

export an open-todos gauge and chart it on the agent dashboard

This commit is contained in:
atlas 2026-11-01 15:08:27 +01:00 • committed by mara
commit 08b8eb3f73

View file

@ -0,0 +1,25 @@
//! Feeds the count of open (un-acked) todos into an OTEL gauge on a timer.
//! Todos arrive and leave between turns, so the per-turn record would
//! leave the series stale while the agent sleeps.
use std::sync::Arc;
use std::time::Duration;
use crate::todos::Todos;
/// Half the exporter's one-minute interval, so every export carries a
/// value at most one tick old.
const TICK: Duration = Duration::from_secs(30);
/// Background loop: record the open-todo count every [`TICK`]. Detached
/// task — runs for the harness's lifetime; read errors are logged, never
/// fatal.
pub async fn run(todos: Arc<Todos>) {
loop {
match todos.open_count() {
Ok(n) => crate::otel_turn_metrics::record_open_todos(n),
Err(e) => tracing::warn!(error = %e, "open todo count failed"),
}
tokio::time::sleep(TICK).await;
}
}