Skip to content
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

Merged
merged 4 commits into from Feb 26, 2021

Conversation

anuraaga
Copy link
Contributor

Depends on #2406

Fixes #2403

@@ -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.
Copy link
Contributor Author

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

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

@@ -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());
Copy link
Member

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.

Copy link
Contributor Author

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>
@breedx-splk
Copy link
Contributor

breedx-splk commented Feb 25, 2021

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 ! 🏆

@anuraaga anuraaga merged commit 0f32ed4 into open-telemetry:main Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log4j instrumentation hijacks the user's logger
4 participants