Skip to content
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 @@ -19,11 +19,13 @@
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand Down Expand Up @@ -72,6 +74,9 @@ public void methodAdvice(MethodTransformer transformer) {
public static class MDBAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope methodEnter(@Advice.Argument(0) final Message message) {
if (CallDepthThreadLocalMap.incrementCallDepth(MessageListener.class) > 0) {
return null;
}
AgentSpan.Context propagatedContext = propagate().extract(message, GETTER);
AgentSpan span = startSpan(JMS_CONSUME, propagatedContext);
CONSUMER_DECORATE.afterStart(span);
Expand All @@ -93,6 +98,7 @@ public static AgentScope methodEnter(@Advice.Argument(0) final Message message)
public static void methodExit(
@Advice.Enter AgentScope scope, @Advice.Thrown final Throwable throwable) {
if (null != scope) {
CallDepthThreadLocalMap.reset(MessageListener.class);
CONSUMER_DECORATE.onError(scope, throwable);
scope.close();
scope.span().finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.CallDepthThreadLocalMap;
import datadog.trace.bootstrap.instrumentation.api.AgentScope;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand Down Expand Up @@ -72,6 +74,9 @@ public void methodAdvice(MethodTransformer transformer) {
public static class MDBAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static AgentScope methodEnter(@Advice.Argument(0) final Message message) {
if (CallDepthThreadLocalMap.incrementCallDepth(MessageListener.class) > 0) {
return null;
}
AgentSpan.Context propagatedContext = propagate().extract(message, GETTER);
AgentSpan span = startSpan(JMS_CONSUME, propagatedContext);
CONSUMER_DECORATE.afterStart(span);
Expand All @@ -93,6 +98,7 @@ public static AgentScope methodEnter(@Advice.Argument(0) final Message message)
public static void methodExit(
@Advice.Enter AgentScope scope, @Advice.Thrown final Throwable throwable) {
if (null != scope) {
CallDepthThreadLocalMap.reset(MessageListener.class);
CONSUMER_DECORATE.onError(scope, throwable);
scope.close();
scope.span().finish();
Expand Down
Loading