From 12741f548829cceb38a75ad44ebda81ba56bbbf0 Mon Sep 17 00:00:00 2001 From: Andrea Marziali Date: Tue, 26 Nov 2024 16:19:01 +0100 Subject: [PATCH] fix thread propagation on late scheduled stuff --- .../instrumentation/mule-4/build.gradle | 7 ++++++- ...mponentMessageProcessorInstrumentation.java} | 17 +++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) rename dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/{ComponentMessageInstrumentation.java => ComponentMessageProcessorInstrumentation.java} (77%) diff --git a/dd-java-agent/instrumentation/mule-4/build.gradle b/dd-java-agent/instrumentation/mule-4/build.gradle index 3d65328e32c8..7d423da2f590 100644 --- a/dd-java-agent/instrumentation/mule-4/build.gradle +++ b/dd-java-agent/instrumentation/mule-4/build.gradle @@ -14,6 +14,7 @@ muzzle { module = 'mule-core' versions = '[4.5.0,)' javaVersion = "17" + excludeDependency 'om.google.guava:guava' excludeDependency 'com.google.code.findbugs:jsr305' additionalDependencies +="org.mule.runtime:mule-tracer-customization-impl:4.5.0" } @@ -22,6 +23,7 @@ muzzle { module = 'mule-tracer-customization-impl' versions = '[4.5.0,)' javaVersion = "17" + excludeDependency 'om.google.guava:guava' excludeDependency 'com.google.code.findbugs:jsr305' additionalDependencies +="org.mule.runtime:mule-core:4.5.0" } @@ -30,8 +32,9 @@ muzzle { group = 'org.mule.runtime' module = 'mule-core' versions = '[4.5.0,)' - assertInverse true javaVersion = "17" + assertInverse true + excludeDependency 'om.google.guava:guava' excludeDependency 'com.google.code.findbugs:jsr305' additionalDependencies +="org.mule.runtime:mule-tracer-customization-impl:4.5.0" } @@ -119,6 +122,8 @@ dependencies { testImplementation project(':dd-java-agent:instrumentation:grizzly-http-2.3.20') testImplementation project(':dd-java-agent:instrumentation:grizzly-client-1.9') testImplementation project(':dd-java-agent:instrumentation:caffeine') + testImplementation project(':dd-java-agent:instrumentation:quartz-2') + testImplementation group: 'org.mule.runtime', name: 'mule-module-launcher', version: muleVersion testImplementation group: 'org.mule.runtime', name: 'mule-core', version: muleVersion diff --git a/dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageInstrumentation.java b/dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageProcessorInstrumentation.java similarity index 77% rename from dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageInstrumentation.java rename to dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageProcessorInstrumentation.java index 81af01078394..804f615bebdf 100644 --- a/dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageInstrumentation.java +++ b/dd-java-agent/instrumentation/mule-4/src/main/java/datadog/trace/instrumentation/mule4/ComponentMessageProcessorInstrumentation.java @@ -1,14 +1,17 @@ package datadog.trace.instrumentation.mule4; +import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; +import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.namedOneOf; +import static net.bytebuddy.matcher.ElementMatchers.isMethod; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + import com.google.auto.service.AutoService; import datadog.trace.agent.tooling.Instrumenter; import datadog.trace.agent.tooling.InstrumenterModule; -import datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers; import datadog.trace.bootstrap.InstrumentationContext; import datadog.trace.bootstrap.instrumentation.api.AgentScope; import datadog.trace.bootstrap.instrumentation.api.AgentTracer; import net.bytebuddy.asm.Advice; -import net.bytebuddy.matcher.ElementMatchers; import org.mule.runtime.api.event.EventContext; import org.mule.runtime.core.api.event.CoreEvent; import org.mule.runtime.tracer.api.EventTracer; @@ -18,7 +21,7 @@ * handler. */ @AutoService(InstrumenterModule.class) -public class ComponentMessageInstrumentation extends AbstractMuleInstrumentation +public class ComponentMessageProcessorInstrumentation extends AbstractMuleInstrumentation implements Instrumenter.ForSingleType { @Override @@ -29,11 +32,9 @@ public String instrumentedType() { @Override public void methodAdvice(MethodTransformer transformer) { transformer.applyAdvice( - ElementMatchers.isMethod() - .and(NameMatchers.namedOneOf("onEvent", "onEventSynchronous")) - .and( - ElementMatchers.takesArgument( - 0, NameMatchers.named("org.mule.runtime.core.api.event.CoreEvent"))), + isMethod() + .and(namedOneOf("onEvent", "onEventSynchronous", "prepareAndExecuteOperation")) + .and(takesArgument(0, named("org.mule.runtime.core.api.event.CoreEvent"))), getClass().getName() + "$ProcessAdvice"); }