Small reduction in context lookups (#4006)
This commit is contained in:
parent
dc4e239722
commit
c91eda59b5
|
@ -58,8 +58,9 @@ public class Servlet3Advice {
|
|||
.get((Filter) servletOrFilter);
|
||||
}
|
||||
|
||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
||||
if (attachedContext != null && tracer().needsRescoping(attachedContext)) {
|
||||
if (attachedContext != null && tracer().needsRescoping(currentContext, attachedContext)) {
|
||||
attachedContext =
|
||||
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
||||
scope = attachedContext.makeCurrent();
|
||||
|
@ -67,7 +68,6 @@ public class Servlet3Advice {
|
|||
return;
|
||||
}
|
||||
|
||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||
if (attachedContext != null || ServerSpan.fromContextOrNull(currentContext) != null) {
|
||||
// Update context with info from current request to ensure that server span gets the best
|
||||
// possible name.
|
||||
|
|
|
@ -58,8 +58,9 @@ public class JakartaServletServiceAdvice {
|
|||
.get((Filter) servletOrFilter);
|
||||
}
|
||||
|
||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||
Context attachedContext = tracer().getServerContext(httpServletRequest);
|
||||
if (attachedContext != null && tracer().needsRescoping(attachedContext)) {
|
||||
if (attachedContext != null && tracer().needsRescoping(currentContext, attachedContext)) {
|
||||
attachedContext =
|
||||
tracer().updateContext(attachedContext, httpServletRequest, mappingResolver, servlet);
|
||||
scope = attachedContext.makeCurrent();
|
||||
|
@ -67,7 +68,6 @@ public class JakartaServletServiceAdvice {
|
|||
return;
|
||||
}
|
||||
|
||||
Context currentContext = Java8BytecodeBridge.currentContext();
|
||||
if (attachedContext != null || ServerSpan.fromContextOrNull(currentContext) != null) {
|
||||
// Update context with info from current request to ensure that server span gets the best
|
||||
// possible name.
|
||||
|
|
|
@ -266,8 +266,8 @@ public abstract class ServletHttpServerTracer<REQUEST, RESPONSE>
|
|||
|
||||
In this case we have to put the span from the request into current context before continuing.
|
||||
*/
|
||||
public boolean needsRescoping(Context attachedContext) {
|
||||
return !sameTrace(Span.fromContext(Context.current()), Span.fromContext(attachedContext));
|
||||
public boolean needsRescoping(Context currentContext, Context attachedContext) {
|
||||
return !sameTrace(Span.fromContext(currentContext), Span.fromContext(attachedContext));
|
||||
}
|
||||
|
||||
private static boolean sameTrace(Span oneSpan, Span otherSpan) {
|
||||
|
|
Loading…
Reference in New Issue