Set the shutdown gauge earlier in the shutdown process
Co-authored-by: Chris Eager <79161849+eager-signal@users.noreply.github.com>
This commit is contained in:
parent
796dce3cd3
commit
bb0da69c9e
|
@ -8,16 +8,16 @@ package org.whispersystems.textsecuregcm.metrics;
|
||||||
|
|
||||||
import static com.codahale.metrics.MetricRegistry.name;
|
import static com.codahale.metrics.MetricRegistry.name;
|
||||||
|
|
||||||
import io.dropwizard.lifecycle.Managed;
|
|
||||||
import io.micrometer.core.instrument.Gauge;
|
import io.micrometer.core.instrument.Gauge;
|
||||||
import io.micrometer.core.instrument.MeterRegistry;
|
import io.micrometer.core.instrument.MeterRegistry;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
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
|
* 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.
|
* 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);
|
private final AtomicBoolean shuttingDown = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
@ -30,12 +30,7 @@ public class ApplicationShutdownMonitor implements Managed {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() throws Exception {
|
public void lifeCycleStopping(final LifeCycle event) {
|
||||||
shuttingDown.set(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() throws Exception {
|
|
||||||
shuttingDown.set(true);
|
shuttingDown.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,9 @@ public class MetricsUtil {
|
||||||
Metrics.addRegistry(dogstatsdMeterRegistry);
|
Metrics.addRegistry(dogstatsdMeterRegistry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment.lifecycle().addEventListener(new ApplicationShutdownMonitor(Metrics.globalRegistry));
|
||||||
environment.lifecycle().addEventListener(
|
environment.lifecycle().addEventListener(
|
||||||
new MicrometerRegistryManager(Metrics.globalRegistry, config.getDatadogConfiguration().pollingFrequency()));
|
new MicrometerRegistryManager(Metrics.globalRegistry, config.getDatadogConfiguration().pollingFrequency()));
|
||||||
environment.lifecycle().manage(new ApplicationShutdownMonitor(Metrics.globalRegistry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
Loading…
Reference in New Issue