-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
I would like to track the size of the jdbc connection pool.
Spring Boot already expose a number of metrics (see DataSourcePoolMetrics
):
jdbc.connections.active
- number of active connectionsjdbc.connections.min
- minimum number of idle connections in the pooljdbc.connections.max
- maximum number of active connections
What am I missing: the number of idle connections in the pool
I'm expecting the number of connections in the pool to be:
min <= active + idle <= max
Adding a new jdbc.connections.idle
metric would cover this scenario.
Alternatively - and maybe more in line with micrometer philosophy - would be two gauges contributing to jdbc.connections.count
, 1st with tag state=idle
and 2nd with tag state=active
.
This idle-count is currently not exposed by the DataSourcePoolMetadata
abstraction. From a quick look in the javadocs, it seems to be available in most supported DataSources:
- DBCP2 - getNumIdle
- Tomcat - getNumIdle
- Hikari - getIdleConnections
See #12788 for a similar discussion about wait-counts - but that stat was not available on all data sources