pub struct RuntimeMetrics {
pub active_sessions: AtomicUsize,
pub total_sessions: AtomicU64,
pub total_steps: AtomicU64,
pub total_tool_calls: AtomicU64,
pub failed_tool_calls: AtomicU64,
pub backpressure_shed_count: AtomicU64,
pub memory_recall_count: AtomicU64,
pub step_latency: LatencyHistogram,
/* private fields */
}Expand description
Shared runtime metrics. Clone the Arc to share across threads.
Fields§
§active_sessions: AtomicUsizeNumber of agent sessions currently in progress.
total_sessions: AtomicU64Total number of sessions started since the runtime was created.
total_steps: AtomicU64Total number of ReAct steps executed across all sessions.
total_tool_calls: AtomicU64Total number of tool calls dispatched (across all tool names).
failed_tool_calls: AtomicU64Total number of tool calls that returned an error observation.
backpressure_shed_count: AtomicU64Total number of requests shed due to backpressure.
memory_recall_count: AtomicU64Total number of memory recall operations.
step_latency: LatencyHistogramPer-step latency histogram.
Implementations§
Source§impl RuntimeMetrics
impl RuntimeMetrics
Sourcepub fn active_sessions(&self) -> usize
pub fn active_sessions(&self) -> usize
Return the number of agent sessions currently in progress.
Sourcepub fn total_sessions(&self) -> u64
pub fn total_sessions(&self) -> u64
Return the total number of sessions started since the runtime was created.
Sourcepub fn total_steps(&self) -> u64
pub fn total_steps(&self) -> u64
Return the total number of ReAct steps executed across all sessions.
Sourcepub fn total_tool_calls(&self) -> u64
pub fn total_tool_calls(&self) -> u64
Return the total number of tool calls dispatched.
Sourcepub fn failed_tool_calls(&self) -> u64
pub fn failed_tool_calls(&self) -> u64
Return the total number of tool calls that returned an error observation.
Sourcepub fn backpressure_shed_count(&self) -> u64
pub fn backpressure_shed_count(&self) -> u64
Return the total number of requests shed due to backpressure.
Sourcepub fn memory_recall_count(&self) -> u64
pub fn memory_recall_count(&self) -> u64
Return the total number of memory recall operations performed.
Sourcepub fn record_tool_call(&self, tool_name: &str)
pub fn record_tool_call(&self, tool_name: &str)
Increment the call counter for tool_name by 1.
Called automatically by the agent loop when with_metrics is configured.
Sourcepub fn record_tool_failure(&self, tool_name: &str)
pub fn record_tool_failure(&self, tool_name: &str)
Increment the failure counter for tool_name by 1.
Called automatically by the agent loop when a tool returns an error.
Sourcepub fn per_tool_calls_snapshot(&self) -> HashMap<String, u64>
pub fn per_tool_calls_snapshot(&self) -> HashMap<String, u64>
Return a snapshot of per-tool call counts as a HashMap<tool_name, count>.
Sourcepub fn per_tool_failures_snapshot(&self) -> HashMap<String, u64>
pub fn per_tool_failures_snapshot(&self) -> HashMap<String, u64>
Return a snapshot of per-tool failure counts as a HashMap<tool_name, count>.
Sourcepub fn record_agent_tool_call(&self, agent_id: &str, tool_name: &str)
pub fn record_agent_tool_call(&self, agent_id: &str, tool_name: &str)
Increment call counter for (agent_id, tool_name).
Sourcepub fn record_agent_tool_failure(&self, agent_id: &str, tool_name: &str)
pub fn record_agent_tool_failure(&self, agent_id: &str, tool_name: &str)
Increment failure counter for (agent_id, tool_name).
Sourcepub fn per_agent_tool_calls_snapshot(
&self,
) -> HashMap<String, HashMap<String, u64>>
pub fn per_agent_tool_calls_snapshot( &self, ) -> HashMap<String, HashMap<String, u64>>
Snapshot of per-agent, per-tool call counts.
Sourcepub fn per_agent_tool_failures_snapshot(
&self,
) -> HashMap<String, HashMap<String, u64>>
pub fn per_agent_tool_failures_snapshot( &self, ) -> HashMap<String, HashMap<String, u64>>
Snapshot of per-agent, per-tool failure counts.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Capture a complete snapshot of all counters, including per-tool breakdowns.
This is the preferred alternative to to_snapshot — it returns a
named MetricsSnapshot struct instead of an opaque tuple.
Sourcepub fn record_step_latency(&self, ms: u64)
pub fn record_step_latency(&self, ms: u64)
Record a step latency sample.
Sourcepub fn reset(&self)
pub fn reset(&self)
Reset all counters to zero.
Intended for testing. In production, counters are monotonically increasing.
Sourcepub fn to_snapshot(&self) -> (usize, u64, u64, u64, u64, u64, u64)
pub fn to_snapshot(&self) -> (usize, u64, u64, u64, u64, u64, u64)
Capture a snapshot of global counters as plain integers.
Returns (active_sessions, total_sessions, total_steps, total_tool_calls, failed_tool_calls, backpressure_shed_count, memory_recall_count).
For per-tool breakdowns use per_tool_calls_snapshot and
per_tool_failures_snapshot.