Skip to content

Logback sdk install does not work for async appenders #12979

@ataraxis

Description

@ataraxis

Describe the bug

OpenTelemetryAppender.install iterates through all the loggers to find appenders where it should inject the sdk. When using an async appender though, OpenTelemetryAppender is referenced through the async appender rather than directly from a logger so the sdk does not get installed.

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

Appender references would be traversed recursively and the sdk installed on appenders that are only referenced from other appenders.

Actual behavior

Only appenders referenced directly from a logger are iterated. The following can workaround the issue, but it's non-obvious.

    <logger name="dummy" level="OFF">
      <appender-ref ref="otel-sync" />
    </logger>

Javaagent or library instrumentation version

2.11

Environment

JDK: 17
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