1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! phi-telemetry — Observability layer for phi-agent.
//!
//! Collects structured per-turn and per-session metrics via hooks registered
//! on the agent runtime. Metrics are persisted as `session_metrics.json`
//! alongside existing session data.
//!
//! ## Architecture
//!
//! ```text
//! agent-base (TurnContext + on_turn_end hook)
//! ↑
//! phi-telemetry (collector + storage) ← this crate
//! ↑
//! phi-agent / phi-bard (consumers)
//! ```
//!
//! The observer runs in an independent tokio task, communicating with the
//! agent runtime through an mpsc channel. A panic in the observer task never
//! affects the agent.
//!
//! ## Quick start
//!
//! ```ignore
//! use phi_telemetry::{init_telemetry, save_metrics};
//!
//! let handle = init_telemetry(&runtime, session_id, node_id, model);
//! // ... agent runs, metrics accumulate automatically ...
//! handle.shutdown();
//! let session = handle.session.blocking_read();
//! save_metrics(&session, &session_dir)?;
//! ```
pub use ;
pub use ;
pub use ;