From c6865ddbb1728e97e863bce6c0505366513c59bb Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Wed, 20 Sep 2023 14:25:58 +0200 Subject: [PATCH 1/3] chore(metrics): Comment code to make it easier to understand --- src/metrics_utils.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/metrics_utils.rs b/src/metrics_utils.rs index 58edd9d..615e758 100644 --- a/src/metrics_utils.rs +++ b/src/metrics_utils.rs @@ -1,12 +1,16 @@ use metrics::{describe_counter, describe_gauge, describe_histogram}; +// counters pub const OPENED_TOTAL: &str = "mobc_pool_connections_opened_total"; pub const CLOSED_TOTAL: &str = "mobc_pool_connections_closed_total"; -pub const OPEN_CONNECTIONS: &str = "mobc_pool_connections_open"; +// gauges +pub const OPEN_CONNECTIONS: &str = "mobc_pool_connections_open"; pub const ACTIVE_CONNECTIONS: &str = "mobc_pool_connections_busy"; pub const IDLE_CONNECTIONS: &str = "mobc_pool_connections_idle"; pub const WAIT_COUNT: &str = "mobc_client_queries_wait"; + +// histogram pub const WAIT_DURATION: &str = "mobc_client_queries_wait_histogram_ms"; pub fn describe_metrics() { From 3373144ac1a7f4c217f373d36102ad9f452292a1 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Wed, 20 Sep 2023 12:29:24 +0000 Subject: [PATCH 2/3] chore: Remove "client" from metrics names --- src/metrics_utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/metrics_utils.rs b/src/metrics_utils.rs index 615e758..9db01af 100644 --- a/src/metrics_utils.rs +++ b/src/metrics_utils.rs @@ -8,10 +8,10 @@ pub const CLOSED_TOTAL: &str = "mobc_pool_connections_closed_total"; pub const OPEN_CONNECTIONS: &str = "mobc_pool_connections_open"; pub const ACTIVE_CONNECTIONS: &str = "mobc_pool_connections_busy"; pub const IDLE_CONNECTIONS: &str = "mobc_pool_connections_idle"; -pub const WAIT_COUNT: &str = "mobc_client_queries_wait"; +pub const WAIT_COUNT: &str = "mobc_queries_wait"; // histogram -pub const WAIT_DURATION: &str = "mobc_client_queries_wait_histogram_ms"; +pub const WAIT_DURATION: &str = "mobc_queries_wait_histogram_ms"; pub fn describe_metrics() { describe_counter!(OPENED_TOTAL, "Total number of Pool Connections opened"); From 324dcc90b0417dcb4daf1dd138d6a4da46b43668 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Wed, 20 Sep 2023 19:06:24 +0200 Subject: [PATCH 3/3] add README with fixes --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index f3046a6..dfab548 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,19 @@ Some of the connection pool configurations can be adjusted dynamically. Each con - max_idle_closed - The total number of connections closed due to max_idle. - max_lifetime_closed - The total number of connections closed due to max_lifetime. +## Metrics + +- Counters + - `mobc_pool_connections_opened_total` - Total number of Pool Connections opened + - `mobc_pool_connections_closed_total` - Total number of Pool Connections closed +- Gauges + - `mobc_pool_connections_open` - Number of currently open Pool Connections + - `mobc_pool_connections_busy` - Number of currently busy Pool Connections (executing a database query)" + - `mobc_pool_connections_idle` - Number of currently unused Pool Connections (waiting for the next pool query to run) + - `mobc_queries_wait` - Number of queries currently waiting for a connection +- Histograms + - `mobc_queries_wait_histogram_ms` - Histogram of the wait time of all queries in ms + ## Compatibility Because tokio is not compatible with other runtimes, such as async-std. So a database driver written with tokio cannot run in the async-std runtime. For example, you can't use redis-rs in tide because it uses tokio, so the connection pool which bases on redis-res can't be used in tide either.