-
Notifications
You must be signed in to change notification settings - Fork 872
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
OpenTelemetry Log4j appender does not handle non string values #8354
Comments
The root cause might be this? https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/internal/LogEventMapper.java#L163 It doesn't really look like the current design is intended to handle heterogeneous types, especially list/collection types. This test can be added to the
Open to ideas. |
What about flattening maps (unless they are pat of an array)?
|
I think that nested attributes (open-telemetry/opentelemetry-specification#2888) would probably be something we'd want to use here; they're not specced yet though. |
👍 any thoughts what to do in the meantime?
skipping them is probably better from a stability perspective if we are hoping to use nested attributes in the future |
Agree on skipping them 👍 |
When the Log4j
LogEvent
context data contains non string values e.g string arrays or java maps, the resulting attributes are incorrect.Create a class extending
ObjectThreadContextMap
and set it as the default using the log4j system propertylog4j2.threadContextMap
Add the following code:
In the logging code add the following
What did you expect to see?
I would expect that the nested value and the array value would be included in attributes properly.
What did you see instead?
I saw the
.toString()
representations of the array and map. Sonumbers
showed as an attribute with value[Ljava.lang.String
andtestmap
showed up as a single value with the map values as{fn=firstname, ln=lastname}
.What version are you using?
1.23.0-alpha
Log4j: 2.17.1
The text was updated successfully, but these errors were encountered: