diff --git a/instrumentation/tomcat/tomcat-10.0/javaagent/build.gradle.kts b/instrumentation/tomcat/tomcat-10.0/javaagent/build.gradle.kts index 53193a3b747b..1fe531ad4088 100644 --- a/instrumentation/tomcat/tomcat-10.0/javaagent/build.gradle.kts +++ b/instrumentation/tomcat/tomcat-10.0/javaagent/build.gradle.kts @@ -21,6 +21,8 @@ dependencies { // Make sure nothing breaks due to both 7.0 and 10.0 modules being present together testInstrumentation(project(":instrumentation:tomcat:tomcat-7.0:javaagent")) + // testing whether instrumentation still works when javax servlet api is also present + testImplementation("javax.servlet:javax.servlet-api:3.0.1") } tasks { 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 7f77d7485af1..818438826715 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,7 @@ public Tomcat10InstrumentationModule() { @Override public ElementMatcher.Junction classLoaderMatcher() { // only matches tomcat 10.0+ - return hasClassesNamed("jakarta.servlet.ReadListener"); + return hasClassesNamed("jakarta.servlet.http.HttpServletRequest"); } @Override diff --git a/instrumentation/tomcat/tomcat-7.0/javaagent/build.gradle.kts b/instrumentation/tomcat/tomcat-7.0/javaagent/build.gradle.kts index 92d326094944..ea631048dd0d 100644 --- a/instrumentation/tomcat/tomcat-7.0/javaagent/build.gradle.kts +++ b/instrumentation/tomcat/tomcat-7.0/javaagent/build.gradle.kts @@ -22,6 +22,8 @@ dependencies { testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent")) // Make sure nothing breaks due to both 7.0 and 10.0 modules being present together testInstrumentation(project(":instrumentation:tomcat:tomcat-10.0:javaagent")) + // testing whether instrumentation still works when jakarta servlet api is also present + testImplementation("jakarta.servlet:jakarta.servlet-api:5.0.0") testLibrary("org.apache.tomcat.embed:tomcat-embed-core:8.0.41") testLibrary("org.apache.tomcat.embed:tomcat-embed-jasper:8.0.41") 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 1a3afb393f50..2750dce8bea9 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 @@ -7,7 +7,6 @@ import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed; import static java.util.Collections.singletonList; -import static net.bytebuddy.matcher.ElementMatchers.not; import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; @@ -26,7 +25,7 @@ public Tomcat7InstrumentationModule() { @Override public ElementMatcher.Junction classLoaderMatcher() { // does not match tomcat 10.0+ - return not(hasClassesNamed("jakarta.servlet.ReadListener")); + return hasClassesNamed("javax.servlet.http.HttpServletRequest"); } @Override