-
Notifications
You must be signed in to change notification settings - Fork 909
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
Support log4j map messages #4966
Conversation
if (message != null) { | ||
builder.setBody(message.getFormattedMessage()); | ||
if (message instanceof MapMessage) { | ||
builder.setBody(message.getFormat()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
...main/java/io/opentelemetry/instrumentation/log4j/appender/v2_16/internal/LogEventMapper.java
Show resolved
Hide resolved
* Support log4j map messages * Cache attribute keys * Review * Add tests * Fix test * Codenarc * Better tests * Remove sysout
Introduces experimental setting
otel.instrumentation.log4j-appender.experimental.capture-map-message-attributes
to capture log4jMapMessage
key/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.