-
Notifications
You must be signed in to change notification settings - Fork 873
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
OTel Spring starter - Automatically add the OTel log appenders #8920
Comments
Two topics:
|
I took a look for Logack. The implementation could be based on Configurator. See also DefaultJoranConfigurator. I could help to verify it works with GraalVM native. |
In this way the Logback appender would be configured before the Spring initialisations and the Spring logs should be appended. |
This implementation may not work well with the Spring Boot initialisations (see AbstractLoggingSystem). An alternative implementation may be to add the OTel Logback appender (if it is not declared in an xml file) from a new logging system (see LogbackLoggingSystem and this configuration). |
Here's an approach I took with another spring starter: https://github.com/grafana/grafana-opentelemetry-starter/blob/d0a762e8d4fc27436db04b0e0a5ff77d1209d01a/src/main/java/com/grafana/opentelemetry/LogAppenderConfigurer.java#L5 |
@zeitlinger Thanks for sharing. With this approach, the OpenTelemetry appender is added during the creation of the OpenTelemetry bean. However, some logs can be emited before this. The two other approaches I mentioned above should not have this limitation (if they work). |
I remember that we discussed the challenge of having an otel instance early enough - because beans are not available at the early stage when logs can be emitted. IIRC, you'd have to cache the log lines from this sage. |
Today, users must declare the OpenTelemetry appender in an xml file ( The logs placed in a queue (see this for Logback and this for Log4j2) until an OpenTelemetry instance is injected into the OpenTelemetry appender. The logs in the queue are then re-emitted. In this way (xml file and logs kept until the OpenTelemetry injection), all the logs are instrumented. This issue aims to remove the need to declare the OpenTelemetry appender in an XML file when no optional setting is required (captureCodeAttributes, ...), the default configuration. The OpenTelemtetry appender has to be created and configured early at the application startup to be able to instrument all the logs. Logback provides the |
An implementation based on a Spring logging system seems to work. I have created a draft PR: #10092 (tested with the OTel starter smoke tests). |
Great stuff - thanks for explaining how everything works together |
It seems that only one logging system could be enabled in Spring Boot. So, the implementation of this PR would disable the Another approach could be to add the OpenTelemetry appender from an application listener executed just after the LoggingApplicationListener. |
Implemented for Logback, the default logging system in Spring Boot. Log4j 2 does not work today with GraalVM native images. So it seems reasonable to close this issue. |
See #8920 (comment)
The text was updated successfully, but these errors were encountered: