diff --git a/docs/source/metrics/metrics.md b/docs/source/metrics/metrics.md index 1393ed587..aa7ac837e 100644 --- a/docs/source/metrics/metrics.md +++ b/docs/source/metrics/metrics.md @@ -1,5 +1,7 @@ # Driver metrics +This feature is available only under the crate feature `metrics`. + During operation the driver collects various metrics. They can be accessed at any moment using `Session::get_metrics()` @@ -11,6 +13,9 @@ They can be accessed at any moment using `Session::get_metrics()` * Total number of paged queries * Number of errors during paged queries * Number of retries +* Latency histogram statistics (min, max, mean, standard deviation, percentiles) +* Rates of queries per second in various time frames +* Number of active connections, and connection and request timeouts ### Example ```rust @@ -29,6 +34,27 @@ println!( "99.9 latency percentile: {}", metrics.get_latency_percentile_ms(99.9).unwrap() ); + +let snapshot = metrics.get_snapshot().unwrap(); +println!("Min: {}", snapshot.min); +println!("Max: {}", snapshot.max); +println!("Mean: {}", snapshot.mean); +println!("Standard deviation: {}", snapshot.stddev); +println!("Median: {}", snapshot.median); +println!("75th percentile: {}", snapshot.percentile_75); +println!("95th percentile: {}", snapshot.percentile_95); +println!("98th percentile: {}", snapshot.percentile_98); +println!("99th percentile: {}", snapshot.percentile_99); +println!("99.9th percentile: {}", snapshot.percentile_99_9); + +println!("Mean rate: {}", metrics.get_mean_rate()); +println!("One minute rate: {}", metrics.get_one_minute_rate()); +println!("Five minute rate: {}", metrics.get_five_minute_rate()); +println!("Fifteen minute rate: {}", metrics.get_fifteen_minute_rate()); + +println!("Total connections: {}", metrics.get_total_connections()); +println!("Connection timeouts: {}", metrics.get_connection_timeouts()); +println!("Requests timeouts: {}", metrics.get_request_timeouts()); # Ok(()) # } ``` \ No newline at end of file diff --git a/examples/basic.rs b/examples/basic.rs index df33496a1..7ab0b1c6d 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -100,6 +100,27 @@ async fn main() -> Result<()> { metrics.get_latency_percentile_ms(99.9).unwrap() ); + let snapshot = metrics.get_snapshot().unwrap(); + println!("Min: {}", snapshot.min); + println!("Max: {}", snapshot.max); + println!("Mean: {}", snapshot.mean); + println!("Standard deviation: {}", snapshot.stddev); + println!("Median: {}", snapshot.median); + println!("75th percentile: {}", snapshot.percentile_75); + println!("95th percentile: {}", snapshot.percentile_95); + println!("98th percentile: {}", snapshot.percentile_98); + println!("99th percentile: {}", snapshot.percentile_99); + println!("99.9th percentile: {}", snapshot.percentile_99_9); + + println!("Mean rate: {}", metrics.get_mean_rate()); + println!("One minute rate: {}", metrics.get_one_minute_rate()); + println!("Five minute rate: {}", metrics.get_five_minute_rate()); + println!("Fifteen minute rate: {}", metrics.get_fifteen_minute_rate()); + + println!("Total connections: {}", metrics.get_total_connections()); + println!("Connection timeouts: {}", metrics.get_connection_timeouts()); + println!("Requests timeouts: {}", metrics.get_request_timeouts()); + println!("Ok."); Ok(())