1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Performance Metrics Implementation
//!
//! Provides comprehensive performance tracking for API requests.
//!
//! ## Features
//!
//! - **Latency Tracking**: Min, max, mean, percentiles (p50, p95, p99)
//! - **Throughput Metrics**: Requests per second, bytes transferred
//! - **Error Tracking**: Success/failure counts, error rate
//! - **Time Windows**: Last minute, last hour, all-time stats
//! - **Thread-Safe**: Safe for concurrent use
//!
//! ## Usage
//!
//! ```no_run
//! # use api_huggingface::performance::{PerformanceMetrics, MetricsConfig};
//! # use std::time::Instant;
//! # async fn example() -> Result< (), Box< dyn std::error::Error > > {
//! let metrics = PerformanceMetrics::new(MetricsConfig::default());
//!
//! // Record a request
//! let start = Instant::now();
//! // ... make request ...
//! metrics.record_request(start.elapsed(), true, 1024).await;
//!
//! // Get statistics
//! let snapshot = metrics.snapshot().await;
//! println!("Mean latency : {:?}", snapshot.latency.mean);
//! println!("P95 latency : {:?}", snapshot.latency.p95);
//! println!("Error rate : {:.2}%", snapshot.error_rate() * 100.0);
//! # Ok(())
//! # }
//! ```
pub use ;