Optimization for expensive type matcher
MODIFY
instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet/v2_3/Servlet2Instrumentation.java
instrumentation/servlet/request-2.3/src/main/java/io/opentelemetry/auto/instrumentation/servlet/v2_3/Servlet2Instrumentation.java
@@ -41,7 +41,9 @@ public final class Servlet2Instrumentation extends Instrumenter.Default {
// this is required to make sure servlet 2 instrumentation won't apply to servlet 3
@Override
public ElementMatcher<ClassLoader> classLoaderMatcher() {
- return not(hasClassesNamed("javax.servlet.AsyncEvent", "javax.servlet.AsyncListener"));
+ // Optimization for expensive typeMatcher.
+ return hasClassesNamed("javax.servlet.http.HttpServlet")
+ .and(not(hasClassesNamed("javax.servlet.AsyncEvent", "javax.servlet.AsyncListener")));
}
@Override

Optimization for expensive type matcher (#558)