Restrict dispatcher instrumentation to 2 arguments
To reduce risk of duplicate spans when delegating to a 2+ arg method.
@@ -14,6 +14,7 @@ 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;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
@@ -65,6 +66,7 @@ public final class RequestDispatcherInstrumentation extends Instrumenter.Default
return singletonMap(
named("forward")
.or(named("include"))
+ .and(takesArguments(2))
.and(takesArgument(0, named("javax.servlet.ServletRequest")))
.and(takesArgument(1, named("javax.servlet.ServletResponse")))
.and(isPublic()),
