Avoid logging servlet3 muzzle failure when running on servlet2
MODIFY
instrumentation/servlet/servlet-2.2/javaagent/build.gradle.kts
instrumentation/servlet/servlet-2.2/javaagent/build.gradle.kts
@@ -23,6 +23,7 @@ dependencies {
implementation(project(":instrumentation:servlet:servlet-javax-common:library"))
testInstrumentation(project(":instrumentation:servlet:servlet-javax-common:javaagent"))
+ testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
testLibrary("org.eclipse.jetty:jetty-server:7.0.0.v20091005")
testLibrary("org.eclipse.jetty:jetty-servlet:7.0.0.v20091005")

MODIFY
instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3InstrumentationModule.java
instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3InstrumentationModule.java
package io.opentelemetry.javaagent.instrumentation.servlet.v3_0;
+import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasClassesNamed;
import static java.util.Arrays.asList;
import com.google.auto.service.AutoService;
@@ -14,6 +15,7 @@ import io.opentelemetry.javaagent.instrumentation.servlet.common.async.AsyncCont
import io.opentelemetry.javaagent.instrumentation.servlet.common.async.AsyncStartInstrumentation;
import io.opentelemetry.javaagent.instrumentation.servlet.common.service.ServletAndFilterInstrumentation;
import java.util.List;
+import net.bytebuddy.matcher.ElementMatcher;
@AutoService(InstrumentationModule.class)
public class Servlet3InstrumentationModule extends InstrumentationModule {
@@ -23,6 +25,11 @@ public class Servlet3InstrumentationModule extends InstrumentationModule {
super("servlet", "servlet-3.0");
}
+ @Override
+ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("javax.servlet.ServletRegistration");
+ }
+
@Override
public List<TypeInstrumentation> typeInstrumentations() {
return asList(

Avoid logging servlet3 muzzle failure when running on servlet2 (#4474)