-
Notifications
You must be signed in to change notification settings - Fork 858
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
Structured logging in Slf4J not honoured in log entry Body #12090
Comments
since this is instrumentation related, moving to that repo |
Have a look at https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/logback/logback-appender-1.0/javaagent/README.md There is an option to capture key value pairs as attributes.
I just wanted to point out that even if these attributes were added to the body then it is unlikely to be as json but rather some sort of protobuf encoding. |
Hi @laurit, I see the configuration you linked uses system properties. Regarding your remark about the format of the body, I seem to understand emitting the body (to be clear, I'm referring to the otel data model) in structured format is not supported. |
Environment variables are supported.
Java api currently only support string body, see open-telemetry/opentelemetry-java#6591 Even if that gets resolved we'd need to decide how exactly are we going to structure the body. Enabling structured body by default is probably going to be a breaking change and may require major version change. An additional concern is whether backends are going to be able to make sense of the structured body. |
Understood, thank you for your help @laurit. |
Hi all,
I apologize in advance if this is a known issue, but I could not find any entry clearly describing this issue.
Describe the bug
When a Java application using Slf4j is instrumented, the logs are sent to the OpenTelemetry Collector.
Slf4j provides support for structured logging:
This should result in a log entry with the following Body:
While the log entry is sent to the OpenTelemetry Collector and all the attributes are correctly attached, the Body in the log entry is empty.
Steps to reproduce
Java App dependencies
Java App code
Auto Instrumentation
Image:
ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.33.5
Inspecting Logs
Log entries sent by the application are intercepted at the level of the Collector and printed using a
debug
exporter.What did you expect to see?
Log entries streamed from the app should contain a body consisting of a json object containing the logged fields:
What did you see instead?
The Body field for the log entry is empty.
The fields to not appear anywhere in the logs.
What version and what artifacts are you using?
Auto instrumentation Image:
ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:1.33.5
The text was updated successfully, but these errors were encountered: