Remove micrometer metrics on close (#1700)

Co-authored-by: Iouri Goussev <igoussev@xmatters.com>
pull/1249/head^2
Iouri Goussev 4 years ago committed by GitHub
parent 310505a377
commit b2f45a5441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,10 +67,12 @@ public class MicrometerMetricsTracker implements IMetricsTracker
private final Gauge minConnectionGauge;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private final PoolStats poolStats;
private final MeterRegistry meterRegistry;
MicrometerMetricsTracker(final String poolName, final PoolStats poolStats, final MeterRegistry meterRegistry)
{
this.poolStats = poolStats;
this.meterRegistry = meterRegistry;
this.connectionObtainTimer = Timer.builder(METRIC_NAME_WAIT)
.description("Connection acquire time")
@ -149,4 +151,18 @@ public class MicrometerMetricsTracker implements IMetricsTracker
{
connectionCreation.record(connectionCreatedMillis, TimeUnit.MILLISECONDS);
}
@Override
public void close() {
meterRegistry.remove(connectionObtainTimer);
meterRegistry.remove(connectionTimeoutCounter);
meterRegistry.remove(connectionUsage);
meterRegistry.remove(connectionCreation);
meterRegistry.remove(totalConnectionGauge);
meterRegistry.remove(idleConnectionGauge);
meterRegistry.remove(activeConnectionGauge);
meterRegistry.remove(pendingConnectionGauge);
meterRegistry.remove(maxConnectionGauge);
meterRegistry.remove(minConnectionGauge);
}
}

Loading…
Cancel
Save