All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.javaagent.bootstrap.kafka.KafkaClientsConsumerProcessTracing Maven / Gradle / Ivy

The newest version!
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.javaagent.bootstrap.kafka;

import java.util.function.BooleanSupplier;

// Classes used by multiple instrumentations should be in a bootstrap module to ensure that all
// instrumentations see the same class. Helper classes are injected into each class loader that
// contains an instrumentation that uses them, so instrumentations in different class loaders will
// have separate copies of helper classes.
public final class KafkaClientsConsumerProcessTracing {
  private static final ThreadLocal wrappingEnabled = ThreadLocal.withInitial(() -> true);

  private KafkaClientsConsumerProcessTracing() {}

  public static boolean setEnabled(boolean enabled) {
    boolean previous = wrappingEnabled.get();
    wrappingEnabled.set(enabled);
    return previous;
  }

  public static boolean wrappingEnabled() {
    return wrappingEnabled.get();
  }

  public static BooleanSupplier wrappingEnabledSupplier() {
    return KafkaClientsConsumerProcessTracing::wrappingEnabled;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy