Add classloader matcher to validate scala/akka presence (DataDog/dd-trace-java#1669)
MODIFY
instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java
instrumentation/akka-context-propagation-2.5/src/main/java/io/opentelemetry/instrumentation/auto/akkaconcurrent/AkkaExecutorInstrumentation.java
package io.opentelemetry.instrumentation.auto.akkaconcurrent;
+import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -48,6 +49,12 @@ public final class AkkaExecutorInstrumentation extends AbstractExecutorInstrumen
return false;
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ // Optimization for expensive typeMatcher.
+ return hasClassesNamed(AkkaForkJoinTaskInstrumentation.TASK_CLASS_NAME);
+ }
+
@Override
public Map<String, String> contextStore() {
return singletonMap(AkkaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());

MODIFY
instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java
instrumentation/java-concurrent/src/main/java/io/opentelemetry/instrumentation/auto/javaconcurrent/ScalaExecutorInstrumentation.java
package io.opentelemetry.instrumentation.auto.javaconcurrent;
+import static io.opentelemetry.javaagent.tooling.ClassLoaderMatcher.hasClassesNamed;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
import static net.bytebuddy.matcher.ElementMatchers.named;
@@ -42,6 +43,12 @@ public final class ScalaExecutorInstrumentation extends AbstractExecutorInstrume
super(EXEC_NAME + ".scala_fork_join");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ // Optimization for expensive typeMatcher.
+ return hasClassesNamed(ScalaForkJoinTaskInstrumentation.TASK_CLASS_NAME);
+ }
+
@Override
public Map<String, String> contextStore() {
return singletonMap(ScalaForkJoinTaskInstrumentation.TASK_CLASS_NAME, State.class.getName());

Add classloader matcher to validate scala/akka presence (DataDog/dd-trace-java#1669)