pub struct MetricsCollector { /* private fields */ }Expand description
Metrics collector for gathering and managing metrics
Implementations§
Source§impl MetricsCollector
impl MetricsCollector
Sourcepub fn new() -> MetricsCollector
pub fn new() -> MetricsCollector
Create a new metrics collector
Sourcepub fn with_config(
collection_interval: Duration,
max_histogram_size: usize,
) -> MetricsCollector
pub fn with_config( collection_interval: Duration, max_histogram_size: usize, ) -> MetricsCollector
Create a new metrics collector with custom configuration
Sourcepub async fn record_request(
&self,
method: &str,
response_time: Duration,
success: bool,
)
pub async fn record_request( &self, method: &str, response_time: Duration, success: bool, )
Record a request with timing and success status
Sourcepub async fn record_transport_send(&self, bytes: u64)
pub async fn record_transport_send(&self, bytes: u64)
Record transport send operation
Sourcepub async fn record_transport_receive(&self, bytes: u64)
pub async fn record_transport_receive(&self, bytes: u64)
Record transport receive operation
Sourcepub async fn record_transport_error(&self, error_type: &str)
pub async fn record_transport_error(&self, error_type: &str)
Record transport error
Sourcepub async fn update_connection_count(&self, count: u32)
pub async fn update_connection_count(&self, count: u32)
Update connection count
Sourcepub async fn update_system_metrics(
&self,
active_connections: u32,
memory_usage: u64,
cpu_usage: f64,
)
pub async fn update_system_metrics( &self, active_connections: u32, memory_usage: u64, cpu_usage: f64, )
Update system metrics
Sourcepub async fn get_metrics(&self) -> Metrics
pub async fn get_metrics(&self) -> Metrics
Get current metrics snapshot
Sourcepub async fn export_json(&self) -> Result<String, Error>
pub async fn export_json(&self) -> Result<String, Error>
Export metrics as JSON
Sourcepub async fn export_prometheus(&self) -> String
pub async fn export_prometheus(&self) -> String
Export metrics in Prometheus format
Sourcepub fn collection_interval(&self) -> Duration
pub fn collection_interval(&self) -> Duration
Get metrics collection interval
Sourcepub fn set_collection_interval(&mut self, interval: Duration)
pub fn set_collection_interval(&mut self, interval: Duration)
Set metrics collection interval
Trait Implementations§
Source§impl Default for MetricsCollector
impl Default for MetricsCollector
Source§fn default() -> MetricsCollector
fn default() -> MetricsCollector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MetricsCollector
impl !RefUnwindSafe for MetricsCollector
impl Send for MetricsCollector
impl Sync for MetricsCollector
impl Unpin for MetricsCollector
impl !UnwindSafe for MetricsCollector
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