Class OpenTelemetryAppenderContextDataInjector
- All Implemented Interfaces:
org.apache.logging.log4j.core.ContextDataInjector
Context into Log4j event context data for async logger
handoff.
This uses Log4j's ContextDataInjector extension point instead of ContextDataProvider because
the appender needs to carry the Context object itself, not only string key/value pairs.
Although Log4j 2.17 added ContextDataProvider.supplyStringMap(), Log4j does not call it for every
thread context map. In web-app mode, which is enabled by default when the Servlet API is on the
classpath, Log4j disables thread locals and uses DefaultThreadContextMap. That path calls
ContextDataProvider.supplyContextData(), which is limited to Map<String, String>.
By delegating to Log4j's selected injector first and then adding the Context object to
the resulting StringMap, this works for DefaultThreadContextMap, copy-on-write, and
garbage-free thread context maps.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.logging.log4j.util.StringMapinjectContextData(List<org.apache.logging.log4j.core.config.Property> properties, org.apache.logging.log4j.util.StringMap reusable) org.apache.logging.log4j.util.ReadOnlyStringMap
-
Constructor Details
-
OpenTelemetryAppenderContextDataInjector
public OpenTelemetryAppenderContextDataInjector()
-
-
Method Details
-
injectContextData
public org.apache.logging.log4j.util.StringMap injectContextData(List<org.apache.logging.log4j.core.config.Property> properties, org.apache.logging.log4j.util.StringMap reusable) - Specified by:
injectContextDatain interfaceorg.apache.logging.log4j.core.ContextDataInjector
-
rawContextData
public org.apache.logging.log4j.util.ReadOnlyStringMap rawContextData()- Specified by:
rawContextDatain interfaceorg.apache.logging.log4j.core.ContextDataInjector
-