Skip to content

Add idle count (number of idle connections in pool) to DataSourcePoolMetadata and DataSourcePoolMetrics #17472

@tgeens

Description

@tgeens

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 connections
  • jdbc.connections.min - minimum number of idle connections in the pool
  • jdbc.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:

See #12788 for a similar discussion about wait-counts - but that stat was not available on all data sources

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions