diff --git a/README.md b/README.md index f3046a6..6dea479 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 + - OPENED_TOTAL - Total number of Pool Connections opened + - CLOSED_TOTAL - Total number of Pool Connections closed +- Gauges + - OPEN_CONNECTIONS - Number of currently open Pool Connections + - ACTIVE_CONNECTIONS - Number of currently busy Pool Connections (executing a database query)" + - IDLE_CONNECTIONS - Number of currently unused Pool Connections (waiting for the next pool query to run) + - WAIT_COUNT - Number of queries currently waiting for a connection +- Histograms + - WAIT_DURATION - 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. diff --git a/src/metrics_utils.rs b/src/metrics_utils.rs index 58edd9d..9db01af 100644 --- a/src/metrics_utils.rs +++ b/src/metrics_utils.rs @@ -1,13 +1,17 @@ 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"; -pub const WAIT_DURATION: &str = "mobc_client_queries_wait_histogram_ms"; +pub const WAIT_COUNT: &str = "mobc_queries_wait"; + +// histogram +pub const WAIT_DURATION: &str = "mobc_queries_wait_histogram_ms"; pub fn describe_metrics() { describe_counter!(OPENED_TOTAL, "Total number of Pool Connections opened");