Maintain strong reference to PoolStats for Micrometer gauges (#1108)

Micrometer's gauges were breaking after the `PoolStats` object they weakly referenced was garbage collected. This change holds a strong reference to the `PoolStats` object in `MicrometerMetricsTracker` to avoid this issue.

See http://micrometer.io/docs/concepts#_why_is_my_gauge_reporting_nan_or_disappearing
pull/1113/head
Tommy Ludwig 7 years ago committed by Brett Wooldridge
parent 6ead232623
commit 3a739210ce

@ -34,9 +34,13 @@ public class MicrometerMetricsTracker implements IMetricsTracker
private final Gauge activeConnectionGauge;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final Gauge pendingConnectionGauge;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final PoolStats poolStats;
MicrometerMetricsTracker(final String poolName, final PoolStats poolStats, final MeterRegistry meterRegistry)
{
this.poolStats = poolStats;
this.connectionObtainTimer = Timer.builder(METRIC_NAME_WAIT)
.description("Connection acquire time")
.publishPercentiles(0.95)

Loading…
Cancel
Save