export an open-todos gauge and chart it on the agent dashboard
This commit is contained in:
parent
c273527219
commit
08b8eb3f73
1 changed files with 162 additions and 0 deletions
25
hive-agent/src/todos_gauge.rs
Normal file
25
hive-agent/src/todos_gauge.rs
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue