-
Notifications
You must be signed in to change notification settings - Fork 867
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
Encapsulate logging #6543
Encapsulate logging #6543
Conversation
00b2fa7
to
fdb68c1
Compare
// Prevents conflict with other SLF4J instances. Important for premain. | ||
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j") |
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.
👍
@@ -92,12 +92,12 @@ class JavaagentTestArgumentsProvider( | |||
"-Dotel.metrics.exporter=otlp", | |||
// suppress repeated logging of "No metric data to export - skipping export." | |||
// since PeriodicMetricReader is configured with a short interval | |||
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO", | |||
"-Dio.opentelemetry.javaagent.logging.simple.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO", |
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.
wow thats quite a property name 😂
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentStarterImpl.java
Outdated
Show resolved
Hide resolved
|
||
// org.slf4j package name in the constants will be shaded too |
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.
👍
// trigger loading the provider from the agent CL | ||
LoggerFactory.getILoggerFactory(); |
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.
do we still need to trigger loading?
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.
Yes, probably - the first usage of any slf4j API method causes it to load the actual implementation using SPI; and since it uses the context CL, it might not find the actual implementation. It's safer to just pre-load it here.
...ogging-simple/src/main/java/io/opentelemetry/javaagent/logging/simple/Slf4jSimpleLogger.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
mergeServiceFiles() | ||
|
||
// Prevents configuration naming conflict with other SLF4J instances | ||
relocate("org.slf4j", "io.opentelemetry.javaagent.logging.simple.slf4j") |
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.
it might be better to continue using io.opentelemetry.javaagent.slf4j
as there are people who are using stuff like -Dio.opentelemetry.javaagent.slf4j.simpleLogger.defaultLogLevel=off
and -Dio.opentelemetry.javaagent.slf4j.simpleLogger.logFile=...
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.
Hm, you're right. I dislike the fact that we're exposing the javaagent internals this way, but since we don't have a better logging story I suppose it is a necessity for now. I'll revert to the previous package name.
* Encapsulate actual logging implementation better * Apply suggestions from code review Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * code review comments * revert to the old slf4j package name * spotless Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
* Encapsulate actual logging implementation better * Apply suggestions from code review Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * code review comments * revert to the old slf4j package name * spotless Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
* Encapsulate actual logging implementation better * Apply suggestions from code review Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * code review comments * revert to the old slf4j package name * spotless Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
Depends on #6499
This PR introduces a new
javaagent-internal-logging-simple
module that encapsulates the logging implementation completely (well, almost, except for a couple of tests). Slf4j is removed from bootstrap dependencies, shading relocation lists, and from the agent's "public" (as in, publicly accessible) space.