Performance Monitor • Rust AI Agent SDK

PerformanceMonitor: Performance monitor for tracking function and API performance.

PerformanceMonitor

Defined in the telemetry module.

Rust AI Agent SDK

Performance monitor for tracking function and API performance.

Fields

NameTypeDescription
functionsArc<RwLock<HashMap<StringFunction statistics
apisArc<RwLock<HashMap<StringAPI statistics
start_timeInstantStart time
enabledboolWhether monitoring is enabled

Methods

new

rust
fn new() -> Self

Create a new monitor.

enable

rust
fn enable(&mut self) -> ()

Enable monitoring.

disable

rust
fn disable(&mut self) -> ()

Disable monitoring.

is_enabled

rust
fn is_enabled(&self) -> bool

Check if enabled.

track_function

rust
fn track_function(&self, name: &str, duration: Duration) -> ()

Track a function call.

Parameters:

NameType
name&str
durationDuration

track_api

rust
fn track_api(&self, endpoint: &str, duration: Duration, success: bool, status_code: Option<u16>) -> ()

Track an API call.

Parameters:

NameType
endpoint&str
durationDuration
successbool
status_codeOption&lt;u16&gt;

get_function_stats

rust
fn get_function_stats(&self, name: &str) -> Option<FunctionStats>

Get function stats.

Parameters:

NameType
name&str

get_api_stats

rust
fn get_api_stats(&self, endpoint: &str) -> Option<ApiStats>

Get API stats.

Parameters:

NameType
endpoint&str

all_function_stats

rust
fn all_function_stats(&self) -> Vec<FunctionStats>

Get all function stats.

all_api_stats

rust
fn all_api_stats(&self) -> Vec<ApiStats>

Get all API stats.

slowest_functions

rust
fn slowest_functions(&self, limit: usize) -> Vec<FunctionStats>

Get slowest functions.

Parameters:

NameType
limitusize

slowest_apis

rust
fn slowest_apis(&self, limit: usize) -> Vec<ApiStats>

Get slowest APIs.

Parameters:

NameType
limitusize

elapsed

rust
fn elapsed(&self) -> Duration

Get elapsed time since start.

clear

rust
fn clear(&self) -> ()

Clear all data.

get_report

rust
fn get_report(&self) -> PerformanceReport

Get performance report.

Source

View on GitHub

praisonai/src/telemetry/mod.rs at line 164