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
AThreadContext
that provides storage for MDC based uponAsyncContext
that also includes tracing information in accessors viaAsyncContextInMemoryScopeManager
. Due to the read only nature of making the tracing information available theThreadContext
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 Summary
Constructors Constructor Description ServiceTalkTracingThreadContextMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(java.lang.String key)
java.lang.String
get(java.lang.String key)
java.util.Map<java.lang.String,java.lang.String>
getCopy()
protected java.util.Map<java.lang.String,java.lang.String>
getCopyOrNull()
java.util.Map<java.lang.String,java.lang.String>
getImmutableMapOrNull()
org.apache.logging.log4j.util.StringMap
getReadOnlyContextData()
boolean
isEmpty()
-
-
-
Method Detail
-
get
@Nullable public java.lang.String get(java.lang.String key)
- Specified by:
get
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
get
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap
- Overrides:
get
in classServiceTalkThreadContextMap
-
containsKey
public boolean containsKey(java.lang.String key)
- Specified by:
containsKey
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
containsKey
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap
- Overrides:
containsKey
in classServiceTalkThreadContextMap
-
getCopy
public java.util.Map<java.lang.String,java.lang.String> getCopy()
- Specified by:
getCopy
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
getCopy
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap
- Overrides:
getCopy
in classServiceTalkThreadContextMap
-
getImmutableMapOrNull
@Nullable public java.util.Map<java.lang.String,java.lang.String> getImmutableMapOrNull()
- Specified by:
getImmutableMapOrNull
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
getImmutableMapOrNull
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap
- Overrides:
getImmutableMapOrNull
in classServiceTalkThreadContextMap
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
isEmpty
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap
- Overrides:
isEmpty
in classServiceTalkThreadContextMap
-
getReadOnlyContextData
public org.apache.logging.log4j.util.StringMap getReadOnlyContextData()
- Specified by:
getReadOnlyContextData
in interfaceorg.apache.logging.log4j.spi.ReadOnlyThreadContextMap
- Specified by:
getReadOnlyContextData
in interfaceorg.apache.logging.log4j.spi.ThreadContextMap2
- Overrides:
getReadOnlyContextData
in classServiceTalkThreadContextMap
-
getCopyOrNull
@Nullable protected java.util.Map<java.lang.String,java.lang.String> getCopyOrNull()
- Overrides:
getCopyOrNull
in classServiceTalkThreadContextMap
-
-