Skip to content

Better config flexibility for log4j OpenTelemetryAppender #6409

@svetsch

Description

@svetsch

Is your feature request related to a problem? Please describe.

The LogEventMapper (https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/internal/LogEventMapper.java) lacks of config flexibility. We should be able to specify a simple mapping for fields, at least for context attributes.

Describe the solution you'd like
As a first step, remove the hard-coded prefix 'log4j.context_data.' added to all ThreadContext attributes.
We should be able to configure this prefix.
Then using a kind of mapping using regexp for example would be nice.

Describe alternatives you've considered
So far as a workaround, I'm using transformer in the collector to remap those attributes. But this requires a set and a delete for each key and thus requires to know all the used attributes.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions