Skip to content

Commit

Permalink
Avoid logging servlet3 muzzle failure when running on servlet2 (#4474)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Oct 22, 2021
1 parent 9b8ab5e commit 1dfd865
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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;
Expand All @@ -14,6 +15,7 @@
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 {
Expand All @@ -23,6 +25,11 @@ public Servlet3InstrumentationModule() {
super("servlet", "servlet-3.0");
}

@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
return hasClassesNamed("javax.servlet.ServletRegistration");
}

@Override
public List<TypeInstrumentation> typeInstrumentations() {
return asList(
Expand Down

0 comments on commit 1dfd865

Please sign in to comment.