-
Notifications
You must be signed in to change notification settings - Fork 828
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
Log4j and Logback appenders opt-in to using GlobalOpenTelemetry #8791
Merged
trask
merged 5 commits into
open-telemetry:main
from
jack-berg:log-appender-global-opt-in
Jun 29, 2023
Merged
Log4j and Logback appenders opt-in to using GlobalOpenTelemetry #8791
trask
merged 5 commits into
open-telemetry:main
from
jack-berg:log-appender-global-opt-in
Jun 29, 2023
Conversation
This file contains 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
mateuszrzeszutek
approved these changes
Jun 23, 2023
zeitlinger
reviewed
Jun 23, 2023
laurit
reviewed
Jun 26, 2023
trask
reviewed
Jun 27, 2023
mateuszrzeszutek
approved these changes
Jun 28, 2023
laurit
approved these changes
Jun 28, 2023
trask
approved these changes
Jun 29, 2023
...st/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppenderTest.java
Outdated
Show resolved
Hide resolved
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.
Resolves #8773. Related to comment in #8637.
This adjusts the Log4j and Logback appenders to make the dependency on
GlobalOpenTelemetry.get()
opt-in. As discussed in the 6/22 Java SIG (and elsewhere) theGlobalOpenTelemetry.get()
dependency is problematic because once you call get, you cannot later call set. Since log config happens so early in the app lifecycle, the only practical way to useGlobalOpenTelemetry
is by opting into the autoconfigure side affect via-Dotel.java.global-autoconfigure.enabled=true
.The
GlobalOpenTelemetry.get()
dependency also is not aligned with our general advice against usingGlobalOpenTelemetry
. Despite the fact that usingGlobalOpenTelemetry
is more aligned with the log configuration tendency to use purely XML based configuration, I still think it makes sense for us to not useGlobalOpenTelemetry
by default so that our advice can remain consistent.Some degree of programatic configuration is present in virtually all of our library instrumentation. Though at first glance it feels a bit strange to add a programatic step, I think folks will get over it quickly given the symmetry to setup of other instrumentation (e.g. runtime metrics).
This PR also adjusts the log appender README files to contain instructions on one way of how to perform programatic configuration. There are many variations possible (especially with log4j), including versions which do not include any OpenTelemetry modifications to log4j2.xml / logback.xml.
In a followup PR, we should consider extending the appenders with a cache to store startup logs recorded before
setOpenTelemetry
is called.