diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/ConsumerCoordinatorInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/ConsumerCoordinatorInstrumentation.java index b76616e7d4b..b8b902e7c8a 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/ConsumerCoordinatorInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/ConsumerCoordinatorInstrumentation.java @@ -6,6 +6,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.HashMap; import java.util.Map; @@ -17,6 +18,11 @@ public ConsumerCoordinatorInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public Map contextStore() { Map contextStores = new HashMap<>(2); diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInfoInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInfoInstrumentation.java index de471d54ad7..5e9cbe89b6f 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInfoInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInfoInstrumentation.java @@ -13,6 +13,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.HashMap; import java.util.Map; import net.bytebuddy.description.type.TypeDescription; @@ -30,6 +31,11 @@ public KafkaConsumerInfoInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public Map contextStore() { Map contextStores = new HashMap<>(4); diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInstrumentation.java index 576d9c18f8c..3b279b6e5c2 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaConsumerInstrumentation.java @@ -10,6 +10,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; @@ -24,6 +25,11 @@ public KafkaConsumerInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public Map contextStore() { Map contextStores = new HashMap<>(2); diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaProducerInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaProducerInstrumentation.java index 7bca67754f7..03850a34fd2 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaProducerInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/KafkaProducerInstrumentation.java @@ -10,6 +10,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.Map; @AutoService(InstrumenterModule.class) @@ -20,6 +21,11 @@ public KafkaProducerInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public String instrumentedType() { return "org.apache.kafka.clients.producer.KafkaProducer"; diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/LegacyKafkaConsumerInfoInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/LegacyKafkaConsumerInfoInstrumentation.java index da7558755dd..6390a9c0d4f 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/LegacyKafkaConsumerInfoInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/LegacyKafkaConsumerInfoInstrumentation.java @@ -13,6 +13,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.HashMap; import java.util.Map; import net.bytebuddy.description.type.TypeDescription; @@ -30,6 +31,11 @@ public LegacyKafkaConsumerInfoInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public Map contextStore() { Map contextStores = new HashMap<>(4); diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/MetadataInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/MetadataInstrumentation.java index e02510bae79..21e486f5bf5 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/MetadataInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/MetadataInstrumentation.java @@ -9,6 +9,7 @@ import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; import java.util.Map; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.matcher.ElementMatcher; @@ -21,6 +22,11 @@ public MetadataInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public String hierarchyMarkerType() { return "org.apache.kafka.clients.Metadata"; diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/OffsetCommitCallbackInvokerInstrumentation.java b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/OffsetCommitCallbackInvokerInstrumentation.java index c35ab00e625..a62238dd8ae 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/OffsetCommitCallbackInvokerInstrumentation.java +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/main/java/datadog/trace/instrumentation/kafka_clients38/OffsetCommitCallbackInvokerInstrumentation.java @@ -5,6 +5,7 @@ import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; +import datadog.trace.api.Config; // new - this instrumentation is completely new. // the purpose of this class is to provide us with information on consumer group and cluster ID @@ -14,6 +15,11 @@ public OffsetCommitCallbackInvokerInstrumentation() { super("kafka"); } + @Override + public boolean isEnabled() { + return super.isEnabled() && Config.get().isExperimentalKafkaEnabled(); + } + @Override public String instrumentedType() { return "org.apache.kafka.clients.consumer.internals.OffsetCommitCallbackInvoker"; diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientCustomPropagationConfigTest.groovy b/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientCustomPropagationConfigTest.groovy index 5db495e5904..3270c6eb371 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientCustomPropagationConfigTest.groovy +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientCustomPropagationConfigTest.groovy @@ -52,6 +52,7 @@ class KafkaClientCustomPropagationConfigTest extends AgentTestRunner { super.configurePreAgent() injectSysConfig("dd.kafka.e2e.duration.enabled", "true") + injectSysConfig("dd.trace.experimental.kafka.enabled","true") } @Flaky diff --git a/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientTestBase.groovy b/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientTestBase.groovy index 6476c47f84f..369e1c3c649 100644 --- a/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientTestBase.groovy +++ b/dd-java-agent/instrumentation/kafka-clients-3.8/src/test/groovy/KafkaClientTestBase.groovy @@ -66,6 +66,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase { super.configurePreAgent() injectSysConfig("dd.kafka.e2e.duration.enabled", "true") + injectSysConfig("dd.trace.experimental.kafka.enabled","true") } public static final LinkedHashMap PRODUCER_PATHWAY_EDGE_TAGS diff --git a/dd-trace-api/src/main/java/datadog/trace/api/config/TraceInstrumentationConfig.java b/dd-trace-api/src/main/java/datadog/trace/api/config/TraceInstrumentationConfig.java index 11eece593ab..f461ebfc64d 100644 --- a/dd-trace-api/src/main/java/datadog/trace/api/config/TraceInstrumentationConfig.java +++ b/dd-trace-api/src/main/java/datadog/trace/api/config/TraceInstrumentationConfig.java @@ -158,5 +158,7 @@ public final class TraceInstrumentationConfig { /** If set, the instrumentation will set its resource name on the local root too. */ public static final String AXIS_PROMOTE_RESOURCE_NAME = "trace.axis.promote.resource-name"; + public static final String EXPERIMENTAL_KAFKA_ENABLED = "trace.experimental.kafka.enabled"; + private TraceInstrumentationConfig() {} } diff --git a/internal-api/src/main/java/datadog/trace/api/Config.java b/internal-api/src/main/java/datadog/trace/api/Config.java index dcf3f67af43..27089d90386 100644 --- a/internal-api/src/main/java/datadog/trace/api/Config.java +++ b/internal-api/src/main/java/datadog/trace/api/Config.java @@ -413,6 +413,9 @@ public static String getHostName() { private final boolean kafkaClientPropagationEnabled; private final Set kafkaClientPropagationDisabledTopics; private final boolean kafkaClientBase64DecodingEnabled; + // enable the Kafka-3.8 instrumentation manually until testing issues are resolved. + private final boolean experimentalKafkaEnabled; + private final boolean jmsPropagationEnabled; private final Set jmsPropagationDisabledTopics; private final Set jmsPropagationDisabledQueues; @@ -1564,6 +1567,7 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment()) tryMakeImmutableSet(configProvider.getList(KAFKA_CLIENT_PROPAGATION_DISABLED_TOPICS)); kafkaClientBase64DecodingEnabled = configProvider.getBoolean(KAFKA_CLIENT_BASE64_DECODING_ENABLED, false); + experimentalKafkaEnabled = configProvider.getBoolean(EXPERIMENTAL_KAFKA_ENABLED, false); jmsPropagationEnabled = isPropagationEnabled(true, "jms"); jmsPropagationDisabledTopics = tryMakeImmutableSet(configProvider.getList(JMS_PROPAGATION_DISABLED_TOPICS)); @@ -3045,6 +3049,10 @@ public boolean isKafkaClientBase64DecodingEnabled() { return kafkaClientBase64DecodingEnabled; } + public boolean isExperimentalKafkaEnabled() { + return experimentalKafkaEnabled; + } + public boolean isRabbitPropagationEnabled() { return rabbitPropagationEnabled; }