-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
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
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Outdated
Show resolved
Hide resolved
🔧 The result from spotlessApply was committed to the PR branch. |
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/jbosslogmanager/appender/v1_1/LoggingEventMapper.java
Outdated
Show resolved
Hide resolved
...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 |
What's the next step for getting this merged? |
Waiting. Usually PRs tagged with the milestone will be merged before the next release. Our release cadence is described in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/RELEASING.md#release-cadence |
thanks! I've opened #14887 to propose changing the default in the next major version release |
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