don't re-disable the OpenTelemetry global if it has already been set/disabled. Fix for evmtool usage (#4721)

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/4724/head
garyschulte 2 years ago committed by GitHub
parent 49f32ca22d
commit 36333b3db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsSystemFactory.java

@ -22,6 +22,8 @@ import org.hyperledger.besu.metrics.opentelemetry.OpenTelemetrySystem;
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration; import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
import org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem; import org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem;
import java.util.concurrent.atomic.AtomicBoolean;
import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.OpenTelemetry;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -31,11 +33,14 @@ import org.slf4j.LoggerFactory;
public class MetricsSystemFactory { public class MetricsSystemFactory {
private static final Logger LOG = LoggerFactory.getLogger(MetricsSystemFactory.class); private static final Logger LOG = LoggerFactory.getLogger(MetricsSystemFactory.class);
private static final AtomicBoolean globalOpenTelemetryDisabled = new AtomicBoolean(false);
private MetricsSystemFactory() {} private MetricsSystemFactory() {}
private static void disableGlobalOpenTelemetry() { private static void disableGlobalOpenTelemetry() {
GlobalOpenTelemetry.set(OpenTelemetry.noop()); if (!globalOpenTelemetryDisabled.compareAndExchange(false, true)) {
GlobalOpenTelemetry.set(OpenTelemetry.noop());
}
} }
/** /**

Loading…
Cancel
Save