-
Notifications
You must be signed in to change notification settings - Fork 998
Capture event name in logback/log4j/jboss-logmanager instrumentation #14649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
philsttr
wants to merge
11
commits into
open-telemetry:main
Choose a base branch
from
philsttr:gh-14632-log-event-name
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added a new capture-event-name configuration option to logback/log4j/jboss-logmanager library/javaagent instrumentation that, when true, 1. captures the log event name from the recently undeprecated semantic attribute named `event.name`, and 2. removes the `event.name` attribute from the log event. This allows the log event name to be specified when logging using standard log APIs, rather than having to use the OpenTelemetry SDK log APIs directly. The `event.name` attribute can be captured using any attribute capturing mechanism supported by the log instrumentation. For example, if logback-appender's `captureKeyValuePairAttributes` is true, then an application can specify the `event.name` attribute via an slf4j key/value when logging. Capturing the event name is enabled with the following configuration values, depending on what you're using: * logback-appender-1.0/library - `io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender` - `captureEventName` * logback-appender-1.0/javaagent - `otel.instrumentation.logback-appender.experimental.capture-event-name` * log4j-appender-2.17/library - `io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender` - `captureEventName` * log4j-appender-2.17/javaagent - `otel.instrumentation.log4j-appender.experimental.capture-event-name` * jboss-logmanager-appender-1.1/javaagent - `otel.instrumentation.jboss-logmanager.experimental.capture-event-name` Fixes: open-telemetrygh-14632
laurit
reviewed
Sep 16, 2025
laurit
reviewed
Sep 16, 2025
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Outdated
Show resolved
Hide resolved
🔧 The result from spotlessApply was committed to the PR branch. |
laurit
reviewed
Sep 17, 2025
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Show resolved
Hide resolved
laurit
reviewed
Sep 17, 2025
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Outdated
Show resolved
Hide resolved
laurit
reviewed
Sep 17, 2025
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Show resolved
Hide resolved
Use cached AttributeKeys for dynamic key names in log mappers. Rename setAttributeMaybeEventName to setAttributeOrEventName Clarify capture event name description in readme
Could you also do this for log4j 1.2 instrumentation https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-appender-1.2/javaagent |
Done |
laurit
approved these changes
Sep 19, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a new capture-event-name configuration option to logback/log4j/jboss-logmanager library/javaagent instrumentation that, when true,
event.name
, andevent.name
attribute from the log event.This allows the log event name to be specified when logging using standard log APIs, rather than having to use the OpenTelemetry SDK log APIs directly.
The
event.name
attribute can be captured using any attribute capturing mechanism supported by the log instrumentation. For example, if logback-appender'scaptureKeyValuePairAttributes
is true, then an application can specify theevent.name
attribute via an slf4j key/value when logging.Capturing the event name is enabled with the following configuration values, depending on what you're using:
io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender
-captureEventName
otel.instrumentation.logback-appender.experimental.capture-event-name
io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender
-captureEventName
otel.instrumentation.log4j-appender.experimental.capture-event-name
otel.instrumentation.jboss-logmanager.experimental.capture-event-name
Not supported in java-util-logging instrumentation, since that instrumentation has no mechanism to pass an
event.name
attribute.Fixes: gh-14632