pub struct AgentMonitor { /* private fields */ }Expand description
Agent Monitor for tracking agent execution metrics
Implementations§
Source§impl AgentMonitor
impl AgentMonitor
Sourcepub fn new(config: Option<MonitorConfig>) -> Self
pub fn new(config: Option<MonitorConfig>) -> Self
Create a new AgentMonitor
Sourcepub fn start_tracking(
&mut self,
agent_id: &str,
agent_type: &str,
description: Option<&str>,
)
pub fn start_tracking( &mut self, agent_id: &str, agent_type: &str, description: Option<&str>, )
Start tracking an agent
Sourcepub fn start_tracking_with_timeout(
&mut self,
agent_id: &str,
agent_type: &str,
description: Option<&str>,
timeout: Duration,
)
pub fn start_tracking_with_timeout( &mut self, agent_id: &str, agent_type: &str, description: Option<&str>, timeout: Duration, )
Start tracking an agent with timeout
Sourcepub fn start_tool_call(
&mut self,
agent_id: &str,
tool_name: &str,
input_size: Option<usize>,
) -> String
pub fn start_tool_call( &mut self, agent_id: &str, tool_name: &str, input_size: Option<usize>, ) -> String
Start a tool call and return its ID
Sourcepub fn end_tool_call(
&mut self,
agent_id: &str,
tool_call_id: &str,
success: bool,
error: Option<&str>,
output_size: Option<usize>,
)
pub fn end_tool_call( &mut self, agent_id: &str, tool_call_id: &str, success: bool, error: Option<&str>, output_size: Option<usize>, )
End a tool call
Sourcepub fn record_tokens(&mut self, agent_id: &str, input: usize, output: usize)
pub fn record_tokens(&mut self, agent_id: &str, input: usize, output: usize)
Record token usage for an agent
Sourcepub fn record_api_call(
&mut self,
agent_id: &str,
success: bool,
latency: Option<Duration>,
)
pub fn record_api_call( &mut self, agent_id: &str, success: bool, latency: Option<Duration>, )
Record an API call for an agent
Sourcepub fn record_cost(&mut self, agent_id: &str, cost: f64)
pub fn record_cost(&mut self, agent_id: &str, cost: f64)
Record cost for an agent
Sourcepub fn record_error(&mut self, agent_id: &str, error: &str, phase: Option<&str>)
pub fn record_error(&mut self, agent_id: &str, error: &str, phase: Option<&str>)
Record an error for an agent
Sourcepub fn stop_tracking(&mut self, agent_id: &str, status: AgentExecutionStatus)
pub fn stop_tracking(&mut self, agent_id: &str, status: AgentExecutionStatus)
Stop tracking an agent
Sourcepub fn get_metrics(&self, agent_id: &str) -> Option<&FullAgentMetrics>
pub fn get_metrics(&self, agent_id: &str) -> Option<&FullAgentMetrics>
Get metrics for an agent
Sourcepub fn get_metrics_mut(
&mut self,
agent_id: &str,
) -> Option<&mut FullAgentMetrics>
pub fn get_metrics_mut( &mut self, agent_id: &str, ) -> Option<&mut FullAgentMetrics>
Get mutable metrics for an agent
Sourcepub fn get_all_metrics(&self) -> Vec<&FullAgentMetrics>
pub fn get_all_metrics(&self) -> Vec<&FullAgentMetrics>
Get all metrics
Sourcepub fn get_metrics_by_status(
&self,
status: AgentExecutionStatus,
) -> Vec<&FullAgentMetrics>
pub fn get_metrics_by_status( &self, status: AgentExecutionStatus, ) -> Vec<&FullAgentMetrics>
Get metrics by status
Sourcepub fn remove_metrics(&mut self, agent_id: &str) -> Option<FullAgentMetrics>
pub fn remove_metrics(&mut self, agent_id: &str) -> Option<FullAgentMetrics>
Remove metrics for an agent
Sourcepub fn get_aggregated_stats(&self) -> AggregatedStats
pub fn get_aggregated_stats(&self) -> AggregatedStats
Get aggregated statistics
Sourcepub fn persist_metrics(&self, agent_id: &str) -> Result<()>
pub fn persist_metrics(&self, agent_id: &str) -> Result<()>
Persist metrics for an agent to disk
Sourcepub fn load_metrics(
&mut self,
agent_id: &str,
) -> Result<Option<FullAgentMetrics>>
pub fn load_metrics( &mut self, agent_id: &str, ) -> Result<Option<FullAgentMetrics>>
Load metrics for an agent from disk
Sourcepub fn list_persisted_metrics(&self) -> Result<Vec<String>>
pub fn list_persisted_metrics(&self) -> Result<Vec<String>>
List all persisted metrics
Sourcepub fn delete_persisted_metrics(&self, agent_id: &str) -> Result<bool>
pub fn delete_persisted_metrics(&self, agent_id: &str) -> Result<bool>
Delete persisted metrics for an agent
Sourcepub fn agent_count(&self) -> usize
pub fn agent_count(&self) -> usize
Get the number of tracked agents
Sourcepub fn active_tool_call_count(&self) -> usize
pub fn active_tool_call_count(&self) -> usize
Get the number of active tool calls
Sourcepub fn set_config(&mut self, config: MonitorConfig)
pub fn set_config(&mut self, config: MonitorConfig)
Update configuration
Sourcepub fn config(&self) -> &MonitorConfig
pub fn config(&self) -> &MonitorConfig
Get current configuration
Sourcepub fn set_metrics_dir(&mut self, dir: PathBuf)
pub fn set_metrics_dir(&mut self, dir: PathBuf)
Set metrics directory
Sourcepub fn metrics_dir(&self) -> &PathBuf
pub fn metrics_dir(&self) -> &PathBuf
Get metrics directory
Trait Implementations§
Source§impl Debug for AgentMonitor
impl Debug for AgentMonitor
Auto Trait Implementations§
impl Freeze for AgentMonitor
impl RefUnwindSafe for AgentMonitor
impl Send for AgentMonitor
impl Sync for AgentMonitor
impl Unpin for AgentMonitor
impl UnsafeUnpin for AgentMonitor
impl UnwindSafe for AgentMonitor
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.