Skip to content

Context lost when using Logback async appender #13069

@ataraxis

Description

@ataraxis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions