Throw an exception if metric registries are configured more than once
This commit is contained in:
parent
73e0aea85c
commit
ebecb1caec
|
@ -19,6 +19,8 @@ import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
|
|||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
|
||||
import io.micrometer.statsd.StatsdMeterRegistry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||
import org.whispersystems.textsecuregcm.WhisperServerVersion;
|
||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
||||
|
@ -30,6 +32,10 @@ public class MetricsUtil {
|
|||
|
||||
public static final String PREFIX = "chat";
|
||||
|
||||
private static volatile boolean registeredMetrics = false;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MetricsUtil.class);
|
||||
|
||||
/**
|
||||
* Returns a dot-separated ('.') name for the given class and name parts
|
||||
*/
|
||||
|
@ -48,6 +54,13 @@ public class MetricsUtil {
|
|||
|
||||
public static void configureRegistries(final WhisperServerConfiguration config, final Environment environment,
|
||||
DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager) {
|
||||
|
||||
if (registeredMetrics) {
|
||||
throw new IllegalStateException("Metric registries configured more than once");
|
||||
}
|
||||
|
||||
registeredMetrics = true;
|
||||
|
||||
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue