Move concurrent helpers to bootstrap
RENAME
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AdviceUtils.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/AdviceUtils.java
-package datadog.trace.instrumentation.java.concurrent;
+package datadog.trace.bootstrap.instrumentation.java.concurrent;
import datadog.trace.bootstrap.ContextStore;
-import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import lombok.extern.slf4j.Slf4j;

RENAME
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ExecutorInstrumentationUtils.java
dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/java/concurrent/ExecutorInstrumentationUtils.java
-package datadog.trace.instrumentation.java.concurrent;
+package datadog.trace.bootstrap.instrumentation.java.concurrent;
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.WeakMap;
-import datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper;
-import datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper;
-import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.concurrent.Executor;
import lombok.extern.slf4j.Slf4j;

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AbstractExecutorInstrumentation.java
@@ -133,11 +133,4 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
}
return matcher.and(hasExecutorInterfaceMatcher); // Apply expensive matcher last.
}
-
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AbstractExecutorInstrumentation.class.getPackage().getName() + ".ExecutorInstrumentationUtils"
- };
- }
}

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AkkaExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AkkaExecutorInstrumentation.java
@@ -10,6 +10,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.ExecutorInstrumentationUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/AkkaForkJoinTaskInstrumentation.java
@@ -14,6 +14,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;
@@ -53,13 +54,6 @@ public final class AkkaForkJoinTaskInstrumentation extends Instrumenter.Default
return extendsClass(named(TASK_CLASS_NAME));
}
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AdviceUtils.class.getName(),
- };
- }
-
@Override
public Map<String, String> contextStore() {
final Map<String, String> map = new HashMap<>();

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/CallableInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/CallableInstrumentation.java
@@ -9,6 +9,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;
@@ -35,13 +36,6 @@ public final class CallableInstrumentation extends Instrumenter.Default {
return implementsInterface(named(Callable.class.getName()));
}
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AdviceUtils.class.getName(),
- };
- }
-
@Override
public Map<String, String> contextStore() {
final Map<String, String> map = new HashMap<>();

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/JavaExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/JavaExecutorInstrumentation.java
@@ -10,6 +10,7 @@ import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
import datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.ExecutorInstrumentationUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/JavaForkJoinTaskInstrumentation.java
@@ -10,6 +10,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;
@@ -43,13 +44,6 @@ public final class JavaForkJoinTaskInstrumentation extends Instrumenter.Default
return extendsClass(named(ForkJoinTask.class.getName()));
}
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AdviceUtils.class.getName(),
- };
- }
-
@Override
public Map<String, String> contextStore() {
final Map<String, String> map = new HashMap<>();

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/RunnableInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/RunnableInstrumentation.java
@@ -9,6 +9,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;
@@ -34,13 +35,6 @@ public final class RunnableInstrumentation extends Instrumenter.Default {
return implementsInterface(named(Runnable.class.getName()));
}
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AdviceUtils.class.getName(),
- };
- }
-
@Override
public Map<String, String> contextStore() {
final Map<String, String> map = new HashMap<>();

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ScalaExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ScalaExecutorInstrumentation.java
@@ -9,6 +9,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.ExecutorInstrumentationUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ScalaForkJoinTaskInstrumentation.java
@@ -11,6 +11,7 @@ import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
import datadog.trace.bootstrap.ContextStore;
import datadog.trace.bootstrap.InstrumentationContext;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.AdviceUtils;
import datadog.trace.bootstrap.instrumentation.java.concurrent.State;
import datadog.trace.context.TraceScope;
import java.util.Collections;
@@ -52,13 +53,6 @@ public final class ScalaForkJoinTaskInstrumentation extends Instrumenter.Default
return extendsClass(named(TASK_CLASS_NAME));
}
- @Override
- public String[] helperClassNames() {
- return new String[] {
- AdviceUtils.class.getName(),
- };
- }
-
@Override
public Map<String, String> contextStore() {
final Map<String, String> map = new HashMap<>();

MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ThreadPoolExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ThreadPoolExecutorInstrumentation.java
@@ -8,6 +8,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
+import datadog.trace.bootstrap.instrumentation.java.concurrent.ExecutorInstrumentationUtils;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@@ -38,8 +39,6 @@ public class ThreadPoolExecutorInstrumentation extends Instrumenter.Default {
@Override
public String[] helperClassNames() {
return new String[] {
- ThreadPoolExecutorInstrumentation.class.getPackage().getName()
- + ".ExecutorInstrumentationUtils",
ThreadPoolExecutorInstrumentation.class.getName() + "$GenericRunnable",
};
}
@@ -59,7 +58,7 @@ public class ThreadPoolExecutorInstrumentation extends Instrumenter.Default {
@Advice.This final ThreadPoolExecutor executor,
@Advice.Argument(4) final BlockingQueue<Runnable> queue) {
- if (queue.size() == 0) {
+ if (queue.isEmpty()) {
try {
queue.offer(new GenericRunnable());
queue.clear(); // Remove the Runnable we just added.

Move concurrent helpers to bootstrap