Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tomcat instrumentation when user includes wrong servlet api #10757

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Tomcat10InstrumentationModule() {
@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// only matches tomcat 10.0+
return hasClassesNamed("jakarta.servlet.ReadListener");
return hasClassesNamed("jakarta.servlet.http.HttpServletRequest");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +25,7 @@ public Tomcat7InstrumentationModule() {
@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// does not match tomcat 10.0+
return not(hasClassesNamed("jakarta.servlet.ReadListener"));
return hasClassesNamed("javax.servlet.http.HttpServletRequest");
}

@Override
Expand Down
Loading