//! 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) { 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; } }