diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/ApplicationShutdownMonitor.java b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/ApplicationShutdownMonitor.java index b9f13df8a..b9eb266ad 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/ApplicationShutdownMonitor.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/ApplicationShutdownMonitor.java @@ -8,16 +8,16 @@ package org.whispersystems.textsecuregcm.metrics; import static com.codahale.metrics.MetricRegistry.name; -import io.dropwizard.lifecycle.Managed; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; import java.util.concurrent.atomic.AtomicBoolean; +import org.eclipse.jetty.util.component.LifeCycle; /** * A managed monitor that reports whether the application is shutting down as a metric. That metric can then be used in * conjunction with other indicators to conditionally fire or suppress alerts. */ -public class ApplicationShutdownMonitor implements Managed { +public class ApplicationShutdownMonitor implements LifeCycle.Listener { private final AtomicBoolean shuttingDown = new AtomicBoolean(false); @@ -30,12 +30,7 @@ public class ApplicationShutdownMonitor implements Managed { } @Override - public void start() throws Exception { - shuttingDown.set(false); - } - - @Override - public void stop() throws Exception { + public void lifeCycleStopping(final LifeCycle event) { shuttingDown.set(true); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/MetricsUtil.java b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/MetricsUtil.java index a7e6cffa8..3ae7a3874 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/metrics/MetricsUtil.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/metrics/MetricsUtil.java @@ -61,9 +61,9 @@ public class MetricsUtil { Metrics.addRegistry(dogstatsdMeterRegistry); } + environment.lifecycle().addEventListener(new ApplicationShutdownMonitor(Metrics.globalRegistry)); environment.lifecycle().addEventListener( new MicrometerRegistryManager(Metrics.globalRegistry, config.getDatadogConfiguration().pollingFrequency())); - environment.lifecycle().manage(new ApplicationShutdownMonitor(Metrics.globalRegistry)); } @VisibleForTesting