Reduces scope copies when desired context is already current (#1558)

This commit is contained in:
Adrian Cole
2020-02-13 14:56:47 -08:00
committed by GitHub
parent 707abda92a
commit 47416a8eef
2 changed files with 15 additions and 1 deletions

View File

@@ -54,7 +54,9 @@ final class ScopePassingSpanSubscriber<T> implements SpanSubscription<T>, Scanna
this.subscriber = subscriber;
this.currentTraceContext = currentTraceContext;
this.parent = parent;
this.context = parent != null ? ctx.put(TraceContext.class, parent) : ctx;
this.context = parent != null
&& !parent.equals(ctx.getOrDefault(TraceContext.class, null))
? ctx.put(TraceContext.class, parent) : ctx;
if (log.isTraceEnabled()) {
log.trace("Parent span [" + parent + "], context [" + this.context + "]");
}