-
Couldn't load subscription status.
- Fork 1k
Description
Is your feature request related to a problem? Please describe.
Currently, the logging instrumentations (logback, log4j, java-util-logging, jboss-logmanager) do not capture the unformatted log message. They only capture the formatted log message, with all arguments substituted.
For example, say an application has a log line similar to this:
logger.info("My favorite color is: {}", favoriteColor);And the application calls that log line with various colors. The logging instrumentation would set the log record bodies to:
My favorite color is: blueMy favorite color is: redMy favorite color is: green
This makes it hard for logging backends to identify related messages. For example, say you wanted to create a dashboard for top errors, but only wanted to list one item per pattern, and not one item per unique combination of arguments.
Describe the solution you'd like
I'd like for the OpenTelemetry Java Instrumentation for loggers to optionally be able to capture the unformatted log message as an attribute.
Currently, the log data model does not define a field for the unformatted log message, and the semantic conventions do not define an attribute for the unformatted log message. Therefore, the instrumentation should allow the user to specify the attribute in which to capture the unformatted message.
For example, when using the logback instrumentation via the java agent, the user could specify:
otel.instrumentation.logback-appender.experimental.capture-unformatted-message-attribute=unformatted_message
which configures the logback instrumentation to capture the unformatted message in an attribute named unformatted_message
From the example above, the three events would all have the unformatted_message attribute set to My favorite color is: {}
Ideally this would be implemented across the logback, log4j, java-util-logging, and jboss-logmanager library and agent instrumentations.
Describe alternatives you've considered
No response
Additional context
Might be worth defining a new log.record.unformatted_message attribute semantic convention. Better name suggestions welcome.
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.