Skip to content

Commit

Permalink
JMS: trace Queue and Topic producers when destination is explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali committed Jul 2, 2024
1 parent a9dde4f commit 7d53edb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.jakarta.jms;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.hasInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void methodAdvice(MethodTransformer transformer) {
JMSMessageProducerInstrumentation.class.getName() + "$ProducerAdvice");
transformer.applyAdvice(
named("send")
.and(takesArgument(0, named("jakarta.jms.Destination")))
.and(takesArgument(0, hasInterface(named("jakarta.jms.Destination"))))
.and(takesArgument(1, named("jakarta.jms.Message")))
.and(isPublic()),
JMSMessageProducerInstrumentation.class.getName() + "$ProducerWithDestinationAdvice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class JMS2Test extends AgentTestRunner {
def producer = session.createProducer(destination)
def consumer = session.createConsumer(destination)

producer.send(message)
producer.send(destination, message)

Message receivedMessage = consumer.receive()
// required to finish auto-acknowledged spans
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.instrumentation.jms;

import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.hasInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface;
import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
Expand Down Expand Up @@ -65,7 +66,7 @@ public void methodAdvice(MethodTransformer transformer) {
JMSMessageProducerInstrumentation.class.getName() + "$ProducerAdvice");
transformer.applyAdvice(
named("send")
.and(takesArgument(0, named("javax.jms.Destination")))
.and(takesArgument(0, hasInterface(named("javax.jms.Destination"))))
.and(takesArgument(1, named("javax.jms.Message")))
.and(isPublic()),
JMSMessageProducerInstrumentation.class.getName() + "$ProducerWithDestinationAdvice");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ abstract class JMS1Test extends VersionedNamingTestBase {
when:
sender.send(message1)
sender.send(message2)
sender.send(destination, message2)
sender.send(message3)
TextMessage receivedMessage1 = receiver.receive()
Expand Down

0 comments on commit 7d53edb

Please sign in to comment.