Skip to content

Dropwizard Metrics

Brett Wooldridge edited this page Aug 17, 2015 · 4 revisions

HikariCP 2.2.0+ supports Dropwizard (formerly Codahale) Metrics. 🎉

You can enable metrics recording by configuring a MetricRegistry instance in HikariConfig or HikariDataSource (depending on which you use for configuration). There is a method, setMetricRegistry(MetricRegistry), for this purpose.

Assuming you have configured a MetricRegistry here are the metrics collected by HikariCP, and their names.

<pool name>.pool.Wait

A Timer instance collecting how long requesting threads to getConnection() are waiting for a connection (or timeout exception) from the pool.

<pool name>.pool.Usage

A Histogram instance collecting how long each connection is used before being returned to the pool. This is the "out of pool" or "in-use" time.

<pool name>.pool.TotalConnections

A CachedGauge, refreshed on demand at 1 second resolution, indicating the total number of connections in the pool.

<pool name>.pool.IdleConnections

A CachedGauge, refreshed on demand at 1 second resolution, indicating the number of idle connections in the pool.

<pool name>.pool.ActiveConnections

A CachedGauge, refreshed on demand at 1 second resolution, indicating the number of active (in-use) connections in the pool.

<pool name>.pool.PendingConnections

A CachedGauge, refreshed on demand at 1 second resolution, indicating the number of threads awaiting connections from the pool.

As you can see the pool name is used as part of the name in the MetricRegistry. So you should ensure that you configure a pool name in order to get consistent names in the registry, especially if you have multiple pools in the VM.


Configuring Dropwizard Metrics in Spring Boot

See this Stackoverflow solution.