Conversation
00b2fa7 to
fdb68c1
Compare
| // Prevents conflict with other SLF4J instances. Important for premain. | ||
| relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j") |
| // 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", |
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentStarterImpl.java
Outdated
Show resolved
Hide resolved
| @AutoService(LoggingCustomizer.class) | ||
| public final class Slf4jSimpleLoggingCustomizer implements LoggingCustomizer { | ||
|
|
||
| // org.slf4j package name in the constants will be shaded too |
| // trigger loading the provider from the agent CL | ||
| LoggerFactory.getILoggerFactory(); |
There was a problem hiding this comment.
do we still need to trigger loading?
There was a problem hiding this comment.
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.
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.
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-simplemodule 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.