pub struct AgentMetrics {
pub total_runs: AtomicU64,
pub successful_runs: AtomicU64,
pub failed_runs: AtomicU64,
pub total_input_tokens: AtomicU64,
pub total_output_tokens: AtomicU64,
pub total_tokens: AtomicU64,
pub tool_calls: AtomicU64,
pub total_duration_ms: AtomicU64,
}Expand description
Atomic agent metrics, safe for concurrent updates.
Fields§
§total_runs: AtomicU64Total number of agent runs.
successful_runs: AtomicU64Successful runs.
failed_runs: AtomicU64Failed runs.
total_input_tokens: AtomicU64Total input (prompt) tokens consumed.
total_output_tokens: AtomicU64Total output (completion) tokens consumed.
total_tokens: AtomicU64Total tokens consumed (input + output).
tool_calls: AtomicU64Total tool calls made.
total_duration_ms: AtomicU64Cumulative duration in milliseconds.
Implementations§
Source§impl AgentMetrics
impl AgentMetrics
Sourcepub fn record_success(
&self,
duration_ms: u64,
input_tokens: u64,
output_tokens: u64,
tool_count: u64,
)
pub fn record_success( &self, duration_ms: u64, input_tokens: u64, output_tokens: u64, tool_count: u64, )
Record a successful run.
Sourcepub fn record_failure(&self, duration_ms: u64)
pub fn record_failure(&self, duration_ms: u64)
Record a failed run.
Sourcepub fn snapshot(&self) -> MetricsSnapshot
pub fn snapshot(&self) -> MetricsSnapshot
Take a snapshot of all counters.
Trait Implementations§
Source§impl Debug for AgentMetrics
impl Debug for AgentMetrics
Source§impl Default for AgentMetrics
impl Default for AgentMetrics
Source§fn default() -> AgentMetrics
fn default() -> AgentMetrics
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for AgentMetrics
impl RefUnwindSafe for AgentMetrics
impl Send for AgentMetrics
impl Sync for AgentMetrics
impl Unpin for AgentMetrics
impl UnsafeUnpin for AgentMetrics
impl UnwindSafe for AgentMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more