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
| Name | Type | Description |
|---|---|---|
functions | Arc<RwLock<HashMap<String | Function statistics |
apis | Arc<RwLock<HashMap<String | API statistics |
start_time | Instant | Start time |
enabled | bool | Whether monitoring is enabled |
Methods
new
fn new() -> SelfCreate a new monitor.
enable
fn enable(&mut self) -> ()Enable monitoring.
disable
fn disable(&mut self) -> ()Disable monitoring.
is_enabled
fn is_enabled(&self) -> boolCheck if enabled.
track_function
fn track_function(&self, name: &str, duration: Duration) -> ()Track a function call.
Parameters:
| Name | Type |
|---|---|
name | &str |
duration | Duration |
track_api
fn track_api(&self, endpoint: &str, duration: Duration, success: bool, status_code: Option<u16>) -> ()Track an API call.
Parameters:
| Name | Type |
|---|---|
endpoint | &str |
duration | Duration |
success | bool |
status_code | Option<u16> |
get_function_stats
fn get_function_stats(&self, name: &str) -> Option<FunctionStats>Get function stats.
Parameters:
| Name | Type |
|---|---|
name | &str |
get_api_stats
fn get_api_stats(&self, endpoint: &str) -> Option<ApiStats>Get API stats.
Parameters:
| Name | Type |
|---|---|
endpoint | &str |
all_function_stats
fn all_function_stats(&self) -> Vec<FunctionStats>Get all function stats.
all_api_stats
fn all_api_stats(&self) -> Vec<ApiStats>Get all API stats.
slowest_functions
fn slowest_functions(&self, limit: usize) -> Vec<FunctionStats>Get slowest functions.
Parameters:
| Name | Type |
|---|---|
limit | usize |
slowest_apis
fn slowest_apis(&self, limit: usize) -> Vec<ApiStats>Get slowest APIs.
Parameters:
| Name | Type |
|---|---|
limit | usize |
elapsed
fn elapsed(&self) -> DurationGet elapsed time since start.
clear
fn clear(&self) -> ()Clear all data.
get_report
fn get_report(&self) -> PerformanceReportGet performance report.
Source
View on GitHubpraisonai/src/telemetry/mod.rs at line 164