Class ThreadContextScopeDecorator

java.lang.Object
brave.internal.propagation.CorrelationFieldScopeDecorator
brave.context.log4j2.ThreadContextScopeDecorator
All Implemented Interfaces:
CurrentTraceContext.ScopeDecorator

public final class ThreadContextScopeDecorator
extends brave.internal.propagation.CorrelationFieldScopeDecorator
Adds ThreadContext properties "traceId", "parentId", "spanId" and "sampled" when a span is current. "traceId" and "spanId" are used in log correlation. "parentId" is used for scenarios such as log parsing that reconstructs the trace tree. "sampled" is used as a hint that a span found in logs might be in Zipkin.

Ex.


 tracing = Tracing.newBuilder()
                  .currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
                    .addScopeDecorator(ThreadContextScopeDecorator.create())
                    .build()
                  )
                  ...
                  .build();
 
  • Method Details

    • create

      public static CurrentTraceContext.ScopeDecorator create()
    • get

      protected String get​(String key)
      Specified by:
      get in class brave.internal.propagation.CorrelationFieldScopeDecorator
    • put

      protected void put​(String key, String value)
      Specified by:
      put in class brave.internal.propagation.CorrelationFieldScopeDecorator
    • remove

      protected void remove​(String key)
      Specified by:
      remove in class brave.internal.propagation.CorrelationFieldScopeDecorator