-
Notifications
You must be signed in to change notification settings - Fork 3k
Dropwizard Metrics
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.
A Timer
instance collecting how long requesting threads to getConnection()
are waiting for a connection (or timeout exception) from the pool.
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.
A CachedGauge
, refreshed on demand at 1 second resolution, indicating the total number of connections in the pool.
A CachedGauge
, refreshed on demand at 1 second resolution, indicating the number of idle connections in the pool.
A CachedGauge
, refreshed on demand at 1 second resolution, indicating the number of active (in-use) connections in the pool.
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.
See this Stackoverflow solution.