enable jetty instrumentation for all handlers

This commit is contained in:
Lauri Tulmin 2021-02-15 18:45:58 +02:00
parent d03281ebe3
commit 8a3d077600
2 changed files with 2 additions and 15 deletions

View File

@ -11,7 +11,6 @@ import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
@ -57,25 +56,13 @@ public class JettyInstrumentationModule extends InstrumentationModule {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
// skipping built-in handlers, so that for servlets there will be no span started by jetty.
// this is so that the servlet instrumentation will capture contextPath and servletPath
// normally, which the jetty instrumentation does not capture since jetty doesn't populate
// contextPath and servletPath until right before calling the servlet
// (another option is to instrument ServletHolder.handle() to capture those fields)
return not(named("org.eclipse.jetty.server.handler.HandlerWrapper"))
.and(not(named("org.eclipse.jetty.server.handler.ScopedHandler")))
.and(not(named("org.eclipse.jetty.server.handler.ContextHandler")))
.and(not(named("org.eclipse.jetty.servlet.ServletHandler")))
.and(implementsInterface(named("org.eclipse.jetty.server.Handler")));
return implementsInterface(named("org.eclipse.jetty.server.Handler"));
}
@Override
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
return singletonMap(
named("handle")
// need to capture doHandle() for handlers that extend built-in handlers excluded
// above
.or(named("doHandle"))
.and(takesArgument(0, named("java.lang.String")))
.and(takesArgument(1, named("org.eclipse.jetty.server.Request")))
.and(takesArgument(2, named("javax.servlet.http.HttpServletRequest")))

View File

@ -16,7 +16,7 @@ class JettySmokeTest extends AppServerTest {
}
def getJettySpanName() {
return serverVersion.startsWith("10.") ? "HandlerList.handle" : "HandlerCollection.handle"
"HandlerWrapper.handle"
}
@Override