Fix call depth (#4338)

This commit is contained in:
Trask Stalnaker 2021-10-11 00:42:20 -07:00 committed by GitHub
parent 8f29dfc8f9
commit 87038f2899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -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();

View File

@ -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,