Skip to content
Open
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 @@ -8,6 +8,7 @@
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf;
import static datadog.trace.api.datastreams.DataStreamsTags.Direction.OUTBOUND;
import static datadog.trace.api.datastreams.DataStreamsTags.create;
import static datadog.trace.api.datastreams.DataStreamsTags.createWithExchange;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
Expand Down Expand Up @@ -219,9 +220,17 @@ public static void onEnter(
if (TIME_IN_QUEUE_ENABLED) {
RabbitDecorator.injectTimeInQueueStart(headers);
}
DataStreamsTags tags =
createWithExchange(
"rabbitmq", OUTBOUND, exchange, routingKey != null && !routingKey.isEmpty());
final boolean hasRoutingKey = routingKey != null && !routingKey.isEmpty();
DataStreamsTags tags;
if ((exchange == null || exchange.isEmpty()) && hasRoutingKey) {
// Publishing to the default exchange: the routing key is the destination queue
// name, so record it as the topic (matching the consumer checkpoint). Without
// this the producer has neither a topic nor an exchange and shows up disconnected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the comment, it doesn't add much imo

// in the data streams map.
tags = create("rabbitmq", OUTBOUND, routingKey);
} else {
tags = createWithExchange("rabbitmq", OUTBOUND, exchange, hasRoutingKey);
}
DataStreamsContext dsmContext = DataStreamsContext.fromTags(tags);
defaultPropagator().inject(span.with(dsmContext), headers, SETTER);
props =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ abstract class RabbitMQTestBase extends VersionedNamingTestBase {
if (isDataStreamsEnabled()) {
StatsGroup first = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == 0 }
verifyAll(first) {
tags.hasAllTags("direction:out", "exchange:", "has_routing_key:true", "type:rabbitmq")
tags.hasAllTags("direction:out", "topic:" + queueName, "type:rabbitmq")
}

StatsGroup second = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == first.hash }
Expand Down Expand Up @@ -493,7 +493,7 @@ abstract class RabbitMQTestBase extends VersionedNamingTestBase {
if (isDataStreamsEnabled()) {
StatsGroup first = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == 0 }
verifyAll(first) {
tags.hasAllTags("direction:out", "exchange:", "has_routing_key:true", "type:rabbitmq")
tags.hasAllTags("direction:out", "topic:some-routing-queue", "type:rabbitmq")
}

StatsGroup second = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == first.hash }
Expand Down