Log injection rework#2440
Conversation
2ccc84c to
6373c86
Compare
|
It looks like this mostly addresses the concerns I expressed previously. I'm just interested in the |
066d274 to
75b93e1
Compare
There was a problem hiding this comment.
Maybe not relevant, but we only need to do the switch if the key starts with dd.
619c43a to
f48ae7d
Compare
f48ae7d to
3d276d5
Compare
|
@randomanderson @richardstartin : From what I've been able to find, this happens because log4j1 is compiled using Java < 1.5, which ByteBuddy doesn't support. Any ideas? Also, are you guys on a public Slack / MS Teams channel somewhere for ad-hoc questions? |
|
@randallt We have a slack that you can join chat.datadoghq.com, but this seems like something better suited for a support@datadoghq.com email. |
|
I haven't figured out yet how to get through L1 Support to a dev team for something this technical--it just goes back and forth with them asking for more information, etc. Is there a keyword I can use to avoid that when I know I need a developer/Team lead? This is a very specific question for the implementors of the Datadog Java agent. |
This PR reworks all of the log injection instrumentations.
Problems
ScopeListeneris called quite often. For some backends, the entire MDC is being duplicated on every scope transition!!Solutions
This PR borrows heavily from the opentelemetry instrumentation.
For Logback, log4j1, and JBoss logging
InstrumentationContextGreat part about this approach work is only done when it needs to be. The "publish" is guarded by
if (LogLevel >= INFO){}type constructs. No work is done adding/removing contexts when there's no logging happening.For Log4j2 versions >=2.7
Log4j2 has a built-in mechanism for adding to the context. The instrumentation implements a
ContextDataInjectorFor Log4j2 versions <2.7
This still uses the old
ScopeListenermechanism. I only cleaned up the interface to not use reflection. The interactions ofLoggerConfigandAsyncLoggerConfig(wherecallAppendersis located) is quite complex. In the future, it's something that can be looked into. (Unfortunately, this means there's no unified service tagging for this version range)Testing
The previous tests made assumptions that are no longer true. The smoke tests are a much better fit for testing logging. This PR tests a base version and the latest version for all of the logging backends. This brings the total number of combinations tested to 48.
Future work
InstrumentationContextsupport for Log4j2 versions <2.7 . The current implementation uses the oldScopeListenermechanism