diff --git a/instrumentation/tomcat/tomcat-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/Tomcat10InstrumentationModule.java b/instrumentation/tomcat/tomcat-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/Tomcat10InstrumentationModule.java index 818438826715..0341609b0f1e 100644 --- a/instrumentation/tomcat/tomcat-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/Tomcat10InstrumentationModule.java +++ b/instrumentation/tomcat/tomcat-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v10_0/Tomcat10InstrumentationModule.java @@ -25,7 +25,13 @@ public Tomcat10InstrumentationModule() { @Override public ElementMatcher.Junction classLoaderMatcher() { // only matches tomcat 10.0+ - return hasClassesNamed("jakarta.servlet.http.HttpServletRequest"); + return hasClassesNamed("jakarta.servlet.http.HttpServletRequest") + .and( + // tomcat 10 has at least one of these two classes. Cache$EvictionOrder is present in + // 10.0.0, but is removed before 10.1.0. GenericUser is added before Cache$EvictionOrder + // is removed + hasClassesNamed("org.apache.catalina.users.GenericUser") + .or(hasClassesNamed("org.apache.catalina.webresources.Cache$EvictionOrder"))); } @Override diff --git a/instrumentation/tomcat/tomcat-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/Tomcat7InstrumentationModule.java b/instrumentation/tomcat/tomcat-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/Tomcat7InstrumentationModule.java index 2750dce8bea9..04e9c7a004c2 100644 --- a/instrumentation/tomcat/tomcat-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/Tomcat7InstrumentationModule.java +++ b/instrumentation/tomcat/tomcat-7.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/v7_0/Tomcat7InstrumentationModule.java @@ -25,7 +25,8 @@ public Tomcat7InstrumentationModule() { @Override public ElementMatcher.Junction classLoaderMatcher() { // does not match tomcat 10.0+ - return hasClassesNamed("javax.servlet.http.HttpServletRequest"); + return hasClassesNamed( + "javax.servlet.http.HttpServletRequest", "org.apache.catalina.loader.Constants"); } @Override