Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 7 additions & 3 deletions src/metrics_utils.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down