From 39c11f9466142a209342b02312c4ac85e24ea03d Mon Sep 17 00:00:00 2001 From: Nayeem Kamal Date: Thu, 7 Nov 2024 12:27:26 -0500 Subject: [PATCH] Revert "removed config variable for disabling kafka-clients" (#7908) This reverts commit 8c7495a542f34a947edb7dae7e7b99f86d15fcac. --- .../ConsumerCoordinatorInstrumentation.java | 6 ++++++ .../kafka_clients38/KafkaConsumerInfoInstrumentation.java | 6 ++++++ .../kafka_clients38/KafkaConsumerInstrumentation.java | 6 ++++++ .../kafka_clients38/KafkaProducerInstrumentation.java | 6 ++++++ .../LegacyKafkaConsumerInfoInstrumentation.java | 6 ++++++ .../kafka_clients38/MetadataInstrumentation.java | 6 ++++++ .../OffsetCommitCallbackInvokerInstrumentation.java | 6 ++++++ .../groovy/KafkaClientCustomPropagationConfigTest.groovy | 1 + .../src/test/groovy/KafkaClientTestBase.groovy | 1 + .../trace/api/config/TraceInstrumentationConfig.java | 2 ++ internal-api/src/main/java/datadog/trace/api/Config.java | 8 ++++++++ 11 files changed, 54 insertions(+) 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 0d81bf0ca85..1936ab4fccd 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 @@ -159,5 +159,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 b2cc613f9a9..2fc71685875 100644 --- a/internal-api/src/main/java/datadog/trace/api/Config.java +++ b/internal-api/src/main/java/datadog/trace/api/Config.java @@ -414,6 +414,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; @@ -1567,6 +1570,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)); @@ -3052,6 +3056,10 @@ public boolean isKafkaClientBase64DecodingEnabled() { return kafkaClientBase64DecodingEnabled; } + public boolean isExperimentalKafkaEnabled() { + return experimentalKafkaEnabled; + } + public boolean isRabbitPropagationEnabled() { return rabbitPropagationEnabled; }