Skip to content

Commit da32c80

Browse files
committed
Fix library test to not expect code location with old deps
The library instrumentation cannot capture code location attributes when running with older Log4j2 versions. The override now correctly returns an empty list for all non-testLatestDeps cases, not just AsyncLogger scenarios.
1 parent e9cf224 commit da32c80

File tree

1 file changed

+3
-5
lines changed
  • instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17

1 file changed

+3
-5
lines changed

instrumentation/log4j/log4j-appender-2.17/library/src/test/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/Log4j2Test.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ protected InstrumentationExtension testing() {
3636

3737
@Override
3838
protected List<AttributeAssertion> addCodeLocationAttributes(String methodName) {
39-
// For library tests, AsyncLogger can't capture code location in older versions
40-
String selector = System.getProperty("Log4j2.contextSelector");
41-
boolean async = selector != null && selector.endsWith("AsyncLoggerContextSelector");
42-
if (async && !Boolean.getBoolean("testLatestDeps")) {
43-
// source info is not available by default when async logger is used in non latest dep tests
39+
// Library instrumentation does not capture code location in older versions.
40+
// Code location is only available when using latest deps (which have the necessary APIs).
41+
if (!Boolean.getBoolean("testLatestDeps")) {
4442
return new ArrayList<>();
4543
}
4644

0 commit comments

Comments
 (0)