Fix call depth
MODIFY
instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Advice.java
instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Advice.java
@@ -36,13 +36,13 @@ public class Servlet3Advice {
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
- callDepth = CallDepth.forClass(AppServerBridge.getCallDepthKey());
- callDepth.getAndIncrement();
-
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
return;
}
+ callDepth = CallDepth.forClass(AppServerBridge.getCallDepthKey());
+ callDepth.getAndIncrement();
+
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
Context currentContext = Java8BytecodeBridge.currentContext();

MODIFY
instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/service/JakartaServletServiceAdvice.java
instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/service/JakartaServletServiceAdvice.java
@@ -37,13 +37,13 @@ public class JakartaServletServiceAdvice {
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
- callDepth = CallDepth.forClass(AppServerBridge.getCallDepthKey());
- callDepth.getAndIncrement();
-
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
return;
}
+ callDepth = CallDepth.forClass(AppServerBridge.getCallDepthKey());
+ callDepth.getAndIncrement();
+
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
Context currentContext = Java8BytecodeBridge.currentContext();
@@ -98,12 +98,12 @@ public class JakartaServletServiceAdvice {
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
- boolean topLevel = callDepth.decrementAndGet() == 0;
-
if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
return;
}
+ boolean topLevel = callDepth.decrementAndGet() == 0;
+
helper()
.end(
requestContext,

Fix call depth (#4338)