open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Context lost when using Logback async appender
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Describe the bug
When logging to an otel appender from an async appender, trace id and span id are missing.
Logging directly to the otel appender:
Trace ID: c19c9a3ae2dab1b1950e6073eddb5b8d
Span ID: 38035d648fa52857
Logging through the async appender:
Trace ID:
Span ID:
Steps to reproduce
<appender name="otel-async" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="otel-sync" />
</appender>
<appender name="otel-sync" class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
<captureExperimentalAttributes>true</captureExperimentalAttributes>
<captureMarkerAttribute>true</captureMarkerAttribute>
<captureKeyValuePairAttributes>true</captureKeyValuePairAttributes>
</appender>
<root level="DEBUG">
<appender-ref ref="otel-async"/>
</root>
Expected behavior
Context would be propagated through the async appender to the otel appender so that trace and span ids would be included in log records.
Actual behavior
Trace and span ids are missing.
Javaagent or library instrumentation version
2.12.0
Environment
JDK: OpenJDK 21
OS: Ubuntu 23.10
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided Logback AsyncAppender and OpenTelemetryAppender configuration, then inspect how context is handled between those two appenders. Compare direct and asynchronous logging under OpenJDK 21. Done means trace and span IDs are present in records emitted through the async appender, with coverage for the reported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100