Skip to content

Commit

Permalink
Avoid double instrumenting lambdas on latest spring scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
amarziali committed Nov 26, 2024
1 parent 26ff4a9 commit 6f4bc24
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
package datadog.trace.instrumentation.springscheduling;

import static datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter.ExcludeType.RUNNABLE;
import static net.bytebuddy.matcher.ElementMatchers.isConstructor;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.ExcludeFilterProvider;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.agent.tooling.InstrumenterModule;
import datadog.trace.bootstrap.instrumentation.java.concurrent.ExcludeFilter;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import net.bytebuddy.asm.Advice;

@AutoService(InstrumenterModule.class)
public final class SpringSchedulingInstrumentation extends InstrumenterModule.Tracing
implements Instrumenter.ForSingleType {
implements Instrumenter.ForSingleType, ExcludeFilterProvider {

public SpringSchedulingInstrumentation() {
super("spring-scheduling");
Expand All @@ -35,6 +41,14 @@ public void methodAdvice(MethodTransformer transformer) {
getClass().getName() + "$SpringSchedulingAdvice");
}

@Override
public Map<ExcludeFilter.ExcludeType, ? extends Collection<String>> excludedClasses() {
return Collections.singletonMap(
RUNNABLE,
Collections.singleton(
"org.springframework.scheduling.config.Task$OutcomeTrackingRunnable"));
}

public static class SpringSchedulingAdvice {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onConstruction(
Expand Down

0 comments on commit 6f4bc24

Please sign in to comment.