-
Notifications
You must be signed in to change notification settings - Fork 1k
Add option for logback to capture message template #15423
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
base: main
Are you sure you want to change the base?
Add option for logback to capture message template #15423
Conversation
Added a new `captureTemplate` option to the logback `OpenTelemetryAppender`. Default is false. The new option captures the unformatted log message template in the `log.body.template` log event attribute. Enable in the library by configuring the `OpenTelemetryAppender` with `<captureTemplate>true</captureTemplate>`. Enable in the javaagent by setting `otel.instrumentation.logback-appender.experimental.capture-template=true`. The existing `captureArguments` option previously enabled both capturing the template and arguments. Now `captureArguments` only enables capturing arguments (not the message template). This is a backwards incompatible change to an experimental config option. Users currently setting `captureArguments=true` would now need to set both `captureArguments=true` and `captureTemplate=true` to maintain previous behavior.
d14ed35 to
07ef9f9
Compare
|
failing tests seem unrelated to changes in this PR |
this is an issue - can you create a PR in sem-conv? |
|
Hallo @zeitlinger To clarify, the logback instrumentation already populates the I can submit a PR for http://github.com/open-telemetry/semantic-conventions/issues/1283, but I feel that is a separate, but related, issue. In other words, I don't think this PR should depend on the new sem-conv PR, since the attributes are currently in use. |
agreed |
|
When Currently, the PR implements A, but I think I'm leaning toward B now, to reduce log volume. If I change the implementation to B, then Anybody have any thoughts? |
|
Capturing the logline template & arguments, even when no argument is used, provides the great benefit of enabling log analytics tools to immediately provide log trend analytics without having to parse the logline through CPU & memory intensive log pattern extraction algorithms. I'm not aware of existing log analytics solution that today leverages |
I think this can be done with both option A or B that i mentioned earlier. For option B, if a log event has no |
Reduces log volume when message templates are not being used.
|
I've updated the implementation to option B. This reduces log data volume, makes it easier for users to revert to previous behavior, and still enables usage of the |
Partially implements #15119. Only for logback.
Added a new
captureTemplateoption to the logbackOpenTelemetryAppender. Default isfalse.The new option captures the unformatted log message template in the
log.body.templatelog event attribute proposed in open-telemetry/semantic-conventions#1283.For example:
will result in the
log.body.templateattribute being set toMy favorite color is: {}Enable in the library by configuring the
OpenTelemetryAppenderwith<captureTemplate>true</captureTemplate>.Enable in the javaagent by setting
otel.instrumentation.logback-appender.experimental.capture-template=true.The existing
captureArgumentsoption previously enabled both capturing the template and arguments. However, it was only documented to capture the arguments. NowcaptureArgumentsonly enables capturing arguments (not the message template). This is a backwards incompatible change to an experimental config option. Users currently settingcaptureArguments=truewould now need to set bothcaptureArguments=trueandcaptureTemplate=trueto maintain the previous behavior.This PR only implements this change for logback (not log4j, jboss-logmanager, or java-util-logging). Others could be done in future PRs.