Class CurrentTraceContext.Default
- java.lang.Object
-
- brave.propagation.CurrentTraceContext
-
- brave.propagation.ThreadLocalCurrentTraceContext
-
- brave.propagation.CurrentTraceContext.Default
-
- Enclosing class:
- CurrentTraceContext
public static final class CurrentTraceContext.Default extends ThreadLocalCurrentTraceContext
Default implementation which is backed by a static thread local.A static thread local ensures we have one context per thread, as opposed to one per thread- tracer. This means all tracer instances will be able to see any tracer's contexts.
The trade-off of this (instance-based reference) vs the reverse: trace contexts are not separated by tracer by default. For example, to make a trace invisible to another tracer, you have to use a non-default implementation.
Sometimes people make different instances of the tracer just to change configuration like the local service name. If we used a thread-instance approach, none of these would be able to see eachother's scopes. This would break
Tracing.currentTracer()
scope visibility in a way few would want to debug. It might be phrased as "MySQL always starts a new trace and I don't know why."If you want a different behavior, use a different subtype of
CurrentTraceContext
, possibly your own, or raise an issue and explain what your use case is.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class brave.propagation.ThreadLocalCurrentTraceContext
ThreadLocalCurrentTraceContext.Builder
-
Nested classes/interfaces inherited from class brave.propagation.CurrentTraceContext
CurrentTraceContext.Default, CurrentTraceContext.Scope, CurrentTraceContext.ScopeDecorator
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CurrentTraceContext
create()
Uses a non-inheritable static thread localstatic CurrentTraceContext
inheritable()
Uses an inheritable static thread local which allows arbitrary calls toThread.start()
to automatically inherit this context.-
Methods inherited from class brave.propagation.ThreadLocalCurrentTraceContext
clear, get, newBuilder, newScope
-
Methods inherited from class brave.propagation.CurrentTraceContext
decorateScope, executor, executorService, maybeScope, wrap, wrap
-
-
-
-
Method Detail
-
create
public static CurrentTraceContext create()
Uses a non-inheritable static thread local
-
inheritable
public static CurrentTraceContext inheritable()
Uses an inheritable static thread local which allows arbitrary calls toThread.start()
to automatically inherit this context. This feature is available as it is was the default in Brave 3, because some users couldn't control threads in their applications.This can be a problem in scenarios such as thread pool expansion, leading to data being recorded in the wrong span, or spans with the wrong parent. If you are impacted by this, switch to
create()
.
-
-