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
Instrument log4j to include bugfix of contextdataprovider mechanism. #2407
Conversation
@@ -44,7 +47,12 @@ public void clearEvents() { | |||
|
|||
@Override | |||
public void append(LogEvent logEvent) { | |||
events.add(logEvent); | |||
// Event object may be reused by the framework so copy the data we need. |
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.
Never knew log4j has such an optimization, too bad most spring users never get to see it :D
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.
nice 👍
.../java/io/opentelemetry/javaagent/instrumentation/log4j/v2_13_2/BugFixingInstrumentation.java
Outdated
Show resolved
Hide resolved
@@ -39,8 +39,7 @@ public Log4j2InstrumentationModule() { | |||
|
|||
@Override | |||
public List<TypeInstrumentation> typeInstrumentations() { | |||
// have to return at least 1 type instrumentation so that helpers get injected | |||
return singletonList(new EmptyTypeInstrumentation()); | |||
return Arrays.asList(new BugFixingInstrumentation(), new EmptyTypeInstrumentation()); |
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.
Can you remove EmptyTypeInstrumentation
? It's not needed anymore, since there's an actual type instrumentation in this module.
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.
The bugfix only applies to one of the codepaths in log4j, if it's using the other one it won't ever be applied so still need it.
…opentelemetry/javaagent/instrumentation/log4j/v2_13_2/BugFixingInstrumentation.java Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
It's kinda bonkers to me to include a bugfix by way of instrumentation, but it seems only helpful and also allows the instrumentation to, you know, actually work. 🤘 Thanks for taking that on and getting to the bottom of it so quickly @anuraaga ! 🏆 |
Depends on #2406
Fixes #2403