Skip to content

Add code attributes for log4j1 #13947

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

oliver-zhang
Copy link
Contributor

Add the ability to get code attributes for log4j1

@oliver-zhang oliver-zhang requested a review from a team as a code owner May 29, 2025 07:19
Copy link

linux-foundation-easycla bot commented May 29, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@oliver-zhang oliver-zhang marked this pull request as draft May 29, 2025 07:21
@oliver-zhang oliver-zhang marked this pull request as ready for review May 29, 2025 07:35
@oliver-zhang
Copy link
Contributor Author

/easycla

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.

hi @oliver-zhang! can you add tests for this similar to those in log4j2?

@oliver-zhang
Copy link
Contributor Author

hi @oliver-zhang! can you add tests for this similar to those in log4j2?

Unit tests have been added

@oliver-zhang oliver-zhang requested a review from trask June 6, 2025 01:22
@trask
Copy link
Member

trask commented Jun 19, 2025

hi @oliver-zhang, thanks for your patience, hopefully we should get #13860 merged in the next few days and then you can rebase and update your PR

}

String lineNumber = locationInfo.getLineNumber();
int codeLineNo = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the line numbers always start at 1 ? Just in case it could be safer to initialize it to -1 by default and then test it with >=0 afterwards.

Comment on lines +89 to +94
equalTo(THREAD_NAME, Thread.currentThread().getName()),
equalTo(THREAD_ID, Thread.currentThread().getId()),
equalTo(CODE_NAMESPACE, Log4j1Test.class.getName()),
equalTo(CODE_FUNCTION, "testCodeAttributes"),
satisfies(CODE_LINENO, AbstractLongAssert::isPositive),
equalTo(CODE_FILEPATH, "Log4j1Test.java")));
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use io.opentelemetry.instrumentation.testing.junit.code.SemconvCodeStabilityUtil for assertions, that was added in #13860 and allows to remove the @SuppressWarnings annotation by providing assertions for all the code attributes. This also allows to test both old and new conventions, but here only the old ones are tested which is fine.

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.

3 participants