Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small reduction in context lookups #4006

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ public static void onEnter(
.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();
// We are inside nested servlet/filter/app-server span, don't create new span
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ public static void onEnter(
.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();
// We are inside nested servlet/filter/app-server span, don't create new span
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ public void onTimeout(Context context, long timeout) {
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) {
Expand Down