Set kafka client service name to application default service name.
So that spans inheriting from that client span have application
service name rather than 'kafka'
MODIFY
dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/KafkaDecorator.java
dd-java-agent/instrumentation/kafka-clients-0.11/src/main/java/datadog/trace/instrumentation/kafka_clients/KafkaDecorator.java
@@ -12,6 +12,11 @@ import org.apache.kafka.clients.producer.ProducerRecord;
public abstract class KafkaDecorator extends ClientDecorator {
public static final KafkaDecorator PRODUCER_DECORATE =
new KafkaDecorator() {
+ @Override
+ protected String service() {
+ return "kafka";
+ }
+
@Override
protected String spanKind() {
return Tags.SPAN_KIND_PRODUCER;
@@ -25,6 +30,16 @@ public abstract class KafkaDecorator extends ClientDecorator {
public static final KafkaDecorator CONSUMER_DECORATE =
new KafkaDecorator() {
+ @Override
+ protected String service() {
+ /*
+ Use default service name. Common use-case here is to have consumer span parent
+ children spans in instrumented application. Since service name is inherited it makes
+ sense to default that to application service name rather than 'kafka'.
+ */
+ return null;
+ }
+
@Override
protected String spanKind() {
return Tags.SPAN_KIND_CONSUMER;
@@ -41,11 +56,6 @@ public abstract class KafkaDecorator extends ClientDecorator {
return new String[] {"kafka"};
}
- @Override
- protected String service() {
- return "kafka";
- }
-
@Override
protected String component() {
return "java-kafka";

MODIFY
dd-java-agent/instrumentation/kafka-clients-0.11/src/test/groovy/KafkaClientTest.groovy
dd-java-agent/instrumentation/kafka-clients-0.11/src/test/groovy/KafkaClientTest.groovy
@@ -94,7 +94,7 @@ class KafkaClientTest extends AgentTestRunner {
trace(1, 1) {
// CONSUMER span 0
span(0) {
- serviceName "kafka"
+ serviceName "unnamed-java-app"
operationName "kafka.consume"
resourceName "Consume Topic $SHARED_TOPIC"
spanType "queue"

MODIFY
dd-java-agent/instrumentation/kafka-streams-0.11/src/test/groovy/KafkaStreamsTest.groovy
dd-java-agent/instrumentation/kafka-streams-0.11/src/test/groovy/KafkaStreamsTest.groovy
@@ -172,7 +172,7 @@ class KafkaStreamsTest extends AgentTestRunner {
trace(2, 1) {
// CONSUMER span 0
span(0) {
- serviceName "kafka"
+ serviceName "unnamed-java-app"
operationName "kafka.consume"
resourceName "Consume Topic $STREAM_PROCESSED"
spanType "queue"

Set kafka client service name to application default service name.

So that spans inheriting from that client span have application
service name rather than 'kafka'