Class ServiceTalkTracingThreadContextMap

java.lang.Object
io.servicetalk.log4j2.mdc.utils.ServiceTalkThreadContextMap
io.servicetalk.opentracing.log4j2.ServiceTalkTracingThreadContextMap
All Implemented Interfaces:
org.apache.logging.log4j.spi.CleanableThreadContextMap, org.apache.logging.log4j.spi.ReadOnlyThreadContextMap, org.apache.logging.log4j.spi.ThreadContextMap, org.apache.logging.log4j.spi.ThreadContextMap2

public final class ServiceTalkTracingThreadContextMap extends ServiceTalkThreadContextMap
A ThreadContext that provides storage for MDC based upon AsyncContext that also includes tracing information in accessors via AsyncContextInMemoryScopeManager. Due to the read only nature of making the tracing information available the ThreadContext map-like interface spirit is not strictly followed. This is due to the fact that modifier methods (e.g. ServiceTalkThreadContextMap.put(String, String), ServiceTalkThreadContextMap.clear()) will not have any impact on this class returning tracing information from the accessor methods (e.g. get(String)). The motivation for this behavior is to avoid a tight coupling between changes to the tracing storage having to be replicated in this MDC storage container. The mechanics to orchestrate this add non-negligible complexity/overhead and so this class provides a trade-off to make the tracing information available in MDC.
  • Constructor Details

    • ServiceTalkTracingThreadContextMap

      public ServiceTalkTracingThreadContextMap()
  • Method Details

    • get

      @Nullable public String get(String key)
      Specified by:
      get in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      get in interface org.apache.logging.log4j.spi.ThreadContextMap
      Overrides:
      get in class ServiceTalkThreadContextMap
    • containsKey

      public boolean containsKey(String key)
      Specified by:
      containsKey in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      containsKey in interface org.apache.logging.log4j.spi.ThreadContextMap
      Overrides:
      containsKey in class ServiceTalkThreadContextMap
    • getCopy

      public Map<String,String> getCopy()
      Specified by:
      getCopy in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      getCopy in interface org.apache.logging.log4j.spi.ThreadContextMap
      Overrides:
      getCopy in class ServiceTalkThreadContextMap
    • getImmutableMapOrNull

      @Nullable public Map<String,String> getImmutableMapOrNull()
      Specified by:
      getImmutableMapOrNull in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      getImmutableMapOrNull in interface org.apache.logging.log4j.spi.ThreadContextMap
      Overrides:
      getImmutableMapOrNull in class ServiceTalkThreadContextMap
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      isEmpty in interface org.apache.logging.log4j.spi.ThreadContextMap
      Overrides:
      isEmpty in class ServiceTalkThreadContextMap
    • getReadOnlyContextData

      public org.apache.logging.log4j.util.StringMap getReadOnlyContextData()
      Specified by:
      getReadOnlyContextData in interface org.apache.logging.log4j.spi.ReadOnlyThreadContextMap
      Specified by:
      getReadOnlyContextData in interface org.apache.logging.log4j.spi.ThreadContextMap2
      Overrides:
      getReadOnlyContextData in class ServiceTalkThreadContextMap
    • getCopyOrNull

      @Nullable protected Map<String,String> getCopyOrNull()
      Overrides:
      getCopyOrNull in class ServiceTalkThreadContextMap