Support log4j map messages - #4966
Merged
Merged
Conversation
trask
requested review from
anuraaga,
iNikem,
jkwatson,
laurit,
mateuszrzeszutek,
pavolloffay and
tylerbenson
as code owners
December 22, 2021 19:22
anuraaga
reviewed
Dec 23, 2021
| if (message != null) { | ||
| builder.setBody(message.getFormattedMessage()); | ||
| if (message instanceof MapMessage) { | ||
| builder.setBody(message.getFormat()); |
Contributor
There was a problem hiding this comment.
Weird API :O
Looks like getFormat returns the message for StructuredDataMessage and empty string for StringMapMessage. From what I've seen, it's conventional to use a map message with an attribute message for the body. How about doing instanceof StructuredDataMessage for message.getFormat(), and checking the attribute for StringMapMessage, leaving Body empty if it's not set?
mateuszrzeszutek
approved these changes
Jan 5, 2022
RashmiRam
pushed a commit
to RashmiRam/opentelemetry-auto-instr-java
that referenced
this pull request
May 23, 2022
* Support log4j map messages * Cache attribute keys * Review * Add tests * Fix test * Codenarc * Better tests * Remove sysout
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
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.
Introduces experimental setting
otel.instrumentation.log4j-appender.experimental.capture-map-message-attributesto capture log4jMapMessagekey/value pairs as log attributes.It doesn't add any prefix to those keys because this is going to be the primary mechanism for users to report arbitrary key/value attributes on logs.
I would support enabling the default to true for this setting, since it is critical for supporting structured events, but it is disabled by default in this PR for now.