From 6d1ea9446de47347961ee7396ddefe5fd514bba9 Mon Sep 17 00:00:00 2001 From: Andrea Marziali Date: Wed, 14 May 2025 11:52:15 +0200 Subject: [PATCH 1/2] Fix error mark on http status for IBM liberty --- .../instrumentation/liberty20/LibertyDecorator.java | 2 +- .../instrumentation/liberty20/Liberty20Test.groovy | 13 ++----------- .../instrumentation/liberty23/LibertyDecorator.java | 2 +- .../instrumentation/liberty23/Liberty23Test.groovy | 13 ++----------- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyDecorator.java b/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyDecorator.java index bcbc1c42c16..585a35332b0 100644 --- a/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyDecorator.java +++ b/dd-java-agent/instrumentation/liberty-20/src/main/java/datadog/trace/instrumentation/liberty20/LibertyDecorator.java @@ -100,7 +100,7 @@ public AgentSpan onResponseStatus(AgentSpan span, int status) { // we may have the status during response blocking, but in that case // the status code is not propagated to the servlet layer if (currentStatus == null || !span.isError()) { - span.setHttpStatusCode(status); + super.onResponseStatus(span, status); } return span; } diff --git a/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy b/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy index 56c3ca15dc0..71a3352884b 100644 --- a/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy +++ b/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy @@ -127,15 +127,6 @@ abstract class Liberty20Test extends HttpServerTest { true } - @Override - String expectedResourceName(ServerEndpoint endpoint, String method, URI address) { - if (endpoint.path == '/not-found') { - 'GET /testapp/not-found' - } else { - super.expectedResourceName(endpoint, method, address) - } - } - def 'test blocking on response with commit during the response'() { setup: assumeTrue(testBlockingOnResponse()) @@ -218,7 +209,7 @@ class Liberty20AsyncForkedTest extends Liberty20Test implements TestingGenericHt // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class LibertyServletClassloaderNamingForkedTest extends Liberty20V0ForkedTest { +class LibertyServletClassloaderNamingForkedTest extends Liberty20V0Test { @Override protected void configurePreAgent() { super.configurePreAgent() @@ -232,7 +223,7 @@ class LibertyServletClassloaderNamingForkedTest extends Liberty20V0ForkedTest { // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class Liberty20V0ForkedTest extends Liberty20Test implements TestingGenericHttpNamingConventions.ServerV0 { +class Liberty20V0Test extends Liberty20Test implements TestingGenericHttpNamingConventions.ServerV0 { } @IgnoreIf({ diff --git a/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyDecorator.java b/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyDecorator.java index 633e1952dc7..b65461d0556 100644 --- a/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyDecorator.java +++ b/dd-java-agent/instrumentation/liberty-23/src/main/java/datadog/trace/instrumentation/liberty23/LibertyDecorator.java @@ -100,7 +100,7 @@ public AgentSpan onResponseStatus(AgentSpan span, int status) { // we may have the status during response blocking, but in that case // the status code is not propagated to the servlet layer if (currentStatus == null || !span.isError()) { - span.setHttpStatusCode(status); + super.onResponseStatus(span, status); } return span; } diff --git a/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy b/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy index 805e2dcfe97..c168176fdc4 100644 --- a/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy +++ b/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy @@ -117,15 +117,6 @@ abstract class Liberty23Test extends HttpServerTest { true } - @Override - String expectedResourceName(ServerEndpoint endpoint, String method, URI address) { - if (endpoint.path == '/not-found') { - 'GET /testapp/not-found' - } else { - super.expectedResourceName(endpoint, method, address) - } - } - def 'test blocking on response with commit during the response'() { setup: assumeTrue(testBlockingOnResponse()) @@ -160,7 +151,7 @@ abstract class Liberty23Test extends HttpServerTest { // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class Liberty23V0ForkedTest extends Liberty23Test implements TestingGenericHttpNamingConventions.ServerV0 { +class Liberty23V0Test extends Liberty23Test implements TestingGenericHttpNamingConventions.ServerV0 { } @IgnoreIf({ @@ -176,7 +167,7 @@ class Liberty23V1ForkedTest extends Liberty23Test implements TestingGenericHttpN // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class LibertyServletClassloaderNamingForkedTest extends Liberty23V0ForkedTest { +class LibertyServletClassloaderNamingForkedTest extends Liberty23V0Test { @Override protected void configurePreAgent() { super.configurePreAgent() From e2f2c9a5c85c2f176d2dc763f7eefff1efcf3ba5 Mon Sep 17 00:00:00 2001 From: Andrea Marziali Date: Wed, 14 May 2025 15:53:08 +0200 Subject: [PATCH 2/2] leave tests as forked --- .../trace/instrumentation/liberty20/Liberty20Test.groovy | 4 ++-- .../trace/instrumentation/liberty23/Liberty23Test.groovy | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy b/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy index 71a3352884b..937b0b82c17 100644 --- a/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy +++ b/dd-java-agent/instrumentation/liberty-20/src/test/groovy/datadog/trace/instrumentation/liberty20/Liberty20Test.groovy @@ -209,7 +209,7 @@ class Liberty20AsyncForkedTest extends Liberty20Test implements TestingGenericHt // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class LibertyServletClassloaderNamingForkedTest extends Liberty20V0Test { +class LibertyServletClassloaderNamingForkedTest extends Liberty20V0ForkedTest { @Override protected void configurePreAgent() { super.configurePreAgent() @@ -223,7 +223,7 @@ class LibertyServletClassloaderNamingForkedTest extends Liberty20V0Test { // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class Liberty20V0Test extends Liberty20Test implements TestingGenericHttpNamingConventions.ServerV0 { +class Liberty20V0ForkedTest extends Liberty20Test implements TestingGenericHttpNamingConventions.ServerV0 { } @IgnoreIf({ diff --git a/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy b/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy index c168176fdc4..42c3372008f 100644 --- a/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy +++ b/dd-java-agent/instrumentation/liberty-23/src/test/groovy/datadog/trace/instrumentation/liberty23/Liberty23Test.groovy @@ -151,7 +151,7 @@ abstract class Liberty23Test extends HttpServerTest { // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class Liberty23V0Test extends Liberty23Test implements TestingGenericHttpNamingConventions.ServerV0 { +class Liberty23V0ForkedTest extends Liberty23Test implements TestingGenericHttpNamingConventions.ServerV0 { } @IgnoreIf({ @@ -167,7 +167,7 @@ class Liberty23V1ForkedTest extends Liberty23Test implements TestingGenericHttpN // instrumented while on the the global ignores list System.getProperty('java.vm.name') == 'IBM J9 VM' && System.getProperty('java.specification.version') == '1.8' }) -class LibertyServletClassloaderNamingForkedTest extends Liberty23V0Test { +class LibertyServletClassloaderNamingForkedTest extends Liberty23V0ForkedTest { @Override protected void configurePreAgent() { super.configurePreAgent()