Skip to content

Add messaging.destination.name tag to kafka integrations #8366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (partitioned) {
"$InstrumentationTags.PARTITION" { it >= 0 }
}
Expand Down Expand Up @@ -380,6 +381,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (tombstone) {
"$InstrumentationTags.TOMBSTONE" true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.CONSUMER_GROUP;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.MESSAGING_DESTINATION_NAME;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.OFFSET;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.PARTITION;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.RECORD_QUEUE_TIME_MS;
Expand Down Expand Up @@ -121,6 +122,7 @@ public void onConsume(
span.setResourceName(CONSUMER_RESOURCE_NAME_CACHE.computeIfAbsent(topic, CONSUMER_PREFIX));
span.setTag(PARTITION, record.partition());
span.setTag(OFFSET, record.offset());
span.setTag(MESSAGING_DESTINATION_NAME, topic);
if (consumerGroup != null) {
span.setTag(CONSUMER_GROUP, consumerGroup);
}
Expand Down Expand Up @@ -162,6 +164,7 @@ public void onProduce(
}
final String topic = record.topic() == null ? "kafka" : record.topic();
span.setResourceName(PRODUCER_RESOURCE_NAME_CACHE.computeIfAbsent(topic, PRODUCER_PREFIX));
span.setTag(MESSAGING_DESTINATION_NAME, topic);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (partitioned) {
"$InstrumentationTags.PARTITION" { it >= 0 }
}
Expand Down Expand Up @@ -1112,6 +1113,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (tombstone) {
"$InstrumentationTags.TOMBSTONE" true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class KafkaReactorForkedTest extends AgentTestRunner {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$KafkaClientTestBase.SHARED_TOPIC"
peerServiceFrom(InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS)
defaultTags()
}
Expand Down Expand Up @@ -211,6 +212,7 @@ class KafkaReactorForkedTest extends AgentTestRunner {
"$InstrumentationTags.CONSUMER_GROUP" "sender"
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$KafkaClientTestBase.SHARED_TOPIC"
defaultTags(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.CONSUMER_GROUP;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.MESSAGING_DESTINATION_NAME;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.OFFSET;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.PARTITION;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.RECORD_QUEUE_TIME_MS;
Expand Down Expand Up @@ -121,6 +122,7 @@ public void onConsume(
span.setResourceName(CONSUMER_RESOURCE_NAME_CACHE.computeIfAbsent(topic, CONSUMER_PREFIX));
span.setTag(PARTITION, record.partition());
span.setTag(OFFSET, record.offset());
span.setTag(MESSAGING_DESTINATION_NAME, topic);
if (consumerGroup != null) {
span.setTag(CONSUMER_GROUP, consumerGroup);
}
Expand Down Expand Up @@ -162,6 +164,7 @@ public void onProduce(
}
final String topic = record.topic() == null ? "kafka" : record.topic();
span.setResourceName(PRODUCER_RESOURCE_NAME_CACHE.computeIfAbsent(topic, PRODUCER_PREFIX));
span.setTag(MESSAGING_DESTINATION_NAME, topic);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (partitioned) {
"$InstrumentationTags.PARTITION" { it >= 0 }
}
Expand Down Expand Up @@ -999,6 +1000,7 @@ abstract class KafkaClientTestBase extends VersionedNamingTestBase {
"$InstrumentationTags.KAFKA_BOOTSTRAP_SERVERS" config.get(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG)
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.RECORD_END_TO_END_DURATION_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$SHARED_TOPIC"
if (tombstone) {
"$InstrumentationTags.TOMBSTONE" true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class KafkaStreamsTest extends AgentTestRunner {
tags {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
if ({ isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
}
Expand Down Expand Up @@ -158,6 +159,7 @@ class KafkaStreamsTest extends AgentTestRunner {
"$InstrumentationTags.PARTITION" { it >= 0 }
"$InstrumentationTags.OFFSET" 0
"$InstrumentationTags.PROCESSOR_NAME" "KSTREAM-SOURCE-0000000000"
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
"asdf" "testing"
if ({ isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
Expand All @@ -180,6 +182,7 @@ class KafkaStreamsTest extends AgentTestRunner {
tags {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
if ({ isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
}
Expand All @@ -204,6 +207,7 @@ class KafkaStreamsTest extends AgentTestRunner {
"$InstrumentationTags.OFFSET" 0
"$InstrumentationTags.CONSUMER_GROUP" "sender"
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
"testing" 123
if ({ isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
if ({ isDataStreamsEnabled() }){
"$DDTags.PATHWAY_HASH" { String }
}
Expand Down Expand Up @@ -201,6 +202,7 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
"$InstrumentationTags.PARTITION" { it >= 0 }
"$InstrumentationTags.OFFSET" 0
"$InstrumentationTags.PROCESSOR_NAME" "KSTREAM-SOURCE-0000000000"
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PENDING"
"asdf" "testing"
if ({isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
Expand All @@ -223,6 +225,7 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
tags {
"$Tags.COMPONENT" "java-kafka"
"$Tags.SPAN_KIND" Tags.SPAN_KIND_PRODUCER
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
if ({isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
}
Expand Down Expand Up @@ -267,6 +270,7 @@ abstract class KafkaStreamsTestBase extends VersionedNamingTestBase {
"$InstrumentationTags.OFFSET" 0
"$InstrumentationTags.CONSUMER_GROUP" "sender"
"$InstrumentationTags.RECORD_QUEUE_TIME_MS" { it >= 0 }
"$InstrumentationTags.MESSAGING_DESTINATION_NAME" "$STREAM_PROCESSED"
"testing" 123
if ({isDataStreamsEnabled()}) {
"$DDTags.PATHWAY_HASH" { String }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class InstrumentationTags {
public static final String MESSAGE = "message";
public static final String HANDLER_TYPE = "handler.type";
public static final String KAFKA_BOOTSTRAP_SERVERS = "messaging.kafka.bootstrap.servers";
public static final String MESSAGING_DESTINATION_NAME = "messaging.destination.name";
public static final String QUARTZ_JOB_NAME = "quartz.job.name";
public static final String QUARTZ_JOB_GROUP = "quartz.job.group";
public static final String QUARTZ_TRIGGER_NAME = "quartz.trigger.name";
Expand Down
Loading