Manual merge of tyler/classloader-precheck
package datadog.trace.instrumentation.playws;
+import static datadog.trace.agent.tooling.ClassLoaderMatcher.classLoaderHasNoResources;
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
@@ -20,6 +21,13 @@ public abstract class BasePlayWSClientInstrumentation extends Instrumenter.Defau
super("play-ws");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ // Optimization for expensive typeMatcher.
+ return not(
+ classLoaderHasNoResources("play/shaded/ahc/org/asynchttpclient/AsyncHttpClient.class"));
+ }
+
@Override
public ElementMatcher<? super TypeDescription> typeMatcher() {
// CachingAsyncHttpClient rejects overrides to AsyncHandler
