From 5facb70f18aeba80cbc93c38693e3a2e9ff287cb Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 09:17:48 -0600 Subject: [PATCH 1/9] Add HttpClientTest2 file --- .../agent/test/base/HttpClientTest2.groovy | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest2.groovy diff --git a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest2.groovy b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest2.groovy new file mode 100644 index 00000000000..6e971218ac9 --- /dev/null +++ b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest2.groovy @@ -0,0 +1,42 @@ +package datadog.trace.agent.test.base + +import datadog.trace.core.datastreams.StatsGroup + +// This class tests multiline multivalue headers for those classes that support it. +abstract class HttpClientTest2 extends HttpClientTest{ + + def "test request header #header tag mapping"() { + when: + def url = server.address.resolve("/success") + def status = (value2 == null) ? doRequest(method, url, [[header, value]]) : doRequest(method, url, [[header, value], [header, value2]]) + if (isDataStreamsEnabled()) { + TEST_DATA_STREAMS_WRITER.waitForGroups(1) + } + + then: + status == 200 + assertTraces(2) { + trace(size(1)) { + clientSpan(it, null, method, false, false, url, status, false, null, false, tags) + } + server.distributedRequestTrace(it, trace(0).last(), tags) + } + and: + if (isDataStreamsEnabled()) { + StatsGroup first = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == 0 } + verifyAll(first) { + edgeTags.containsAll(DSM_EDGE_TAGS) + edgeTags.size() == DSM_EDGE_TAGS.size() + } + } + + where: + method | header | value | value2 | tags + 'GET' | 'X-Datadog-Test-Both-Header' | 'foo' | null | [ 'both_header_tag': 'foo' ] + 'GET' | 'X-Datadog-Test-Request-Header' | 'bar' | null | [ 'request_header_tag': 'bar' ] + 'GET' | 'X-Datadog-Test-Both-Header' | 'bar,baz' | null | [ 'both_header_tag': 'bar,baz' ] + 'GET' | 'X-Datadog-Test-Request-Header' | 'foo,bar' | null | [ 'request_header_tag': 'foo,bar' ] + 'GET' | 'X-Datadog-Test-Both-Header' | 'bar,baz' | 'foo' | [ 'both_header_tag': 'bar,baz,foo' ] + 'GET' | 'X-Datadog-Test-Request-Header' | 'foo,bar' | 'baz' | [ 'request_header_tag': 'foo,bar,baz' ] + } +} From 03a5c7025897f4bdd28e8cf211395d59debfad99 Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 09:22:37 -0600 Subject: [PATCH 2/9] Extend HttpClientTest2 for Apache, Grizzly, and Jetty 9.1 --- .../src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy | 4 ++-- .../test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy | 4 ++-- .../src/test/groovy/ApacheHttpAsyncClientTest.groovy | 4 ++-- .../test/groovy/ApacheHttpClientResponseHandlerTest.groovy | 4 ++-- .../src/test/groovy/ApacheHttpClientTest.groovy | 4 ++-- .../src/test/groovy/ApacheHttpAsyncClient5Test.groovy | 4 ++-- .../test/groovy/ApacheHttpClientResponseHandlerTest.groovy | 4 ++-- .../src/test/groovy/ApacheHttpClientTest.groovy | 4 ++-- .../src/test/groovy/GrizzlyAsyncHttpClientTest.groovy | 4 ++-- .../jetty-client-9.1/src/test/groovy/JettyClientTest.groovy | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy index 819d6a5cfe7..41e312bdfa7 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator import org.apache.http.HttpResponse @@ -14,7 +14,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.TimeUnit @Timeout(5) -class ApacheHttpAsyncClientCallbackTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0 { +class ApacheHttpAsyncClientCallbackTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0 { @Shared RequestConfig requestConfig = RequestConfig.custom() diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy index 3cd39faf5ae..2067e026d30 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator import org.apache.http.client.config.RequestConfig @@ -11,7 +11,7 @@ import spock.lang.Timeout import java.util.concurrent.Future @Timeout(5) -class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0{ +class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0{ @Shared RequestConfig requestConfig = RequestConfig.custom() diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy index bc57def64cf..7607412c99c 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy @@ -1,5 +1,5 @@ import datadog.trace.agent.test.asserts.TraceAssert -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpasyncclient.ApacheHttpAsyncClientDecorator import org.apache.http.HttpHost @@ -16,7 +16,7 @@ import spock.lang.Timeout import java.util.concurrent.CountDownLatch @Timeout(5) -abstract class ApacheHttpAsyncClientTest extends HttpClientTest { +abstract class ApacheHttpAsyncClientTest extends HttpClientTest2 { @Shared RequestConfig requestConfig = RequestConfig.custom() diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy index 020ad6eee6c..67c661b4e83 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpclient.ApacheHttpClientDecorator import org.apache.http.HttpResponse @@ -11,7 +11,7 @@ import spock.lang.Shared import spock.lang.Timeout @Timeout(5) -class ApacheHttpClientResponseHandlerTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0 { +class ApacheHttpClientResponseHandlerTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0 { @Shared def client = new DefaultHttpClient() diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy index 1d34b88381e..8ae0778bade 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpclient.ApacheHttpClientDecorator import org.apache.http.HttpHost @@ -13,7 +13,7 @@ import org.apache.http.protocol.BasicHttpContext import spock.lang.Shared import spock.lang.Timeout -abstract class ApacheHttpClientTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0 { +abstract class ApacheHttpClientTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0 { @Shared def client = new DefaultHttpClient() diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy index 162be3c5467..0ca2e5fb456 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpclient5.ApacheHttpClientDecorator import org.apache.hc.client5.http.async.methods.SimpleHttpRequests @@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit import static org.apache.hc.core5.reactor.IOReactorConfig.custom -abstract class ApacheHttpAsyncClient5Test extends HttpClientTest { +abstract class ApacheHttpAsyncClient5Test extends HttpClientTest2 { @Shared def ioReactorConfig = custom() diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy index cee1a8e9770..d42441d2a8f 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpclient5.ApacheHttpClientDecorator import org.apache.hc.client5.http.config.RequestConfig @@ -15,7 +15,7 @@ import spock.lang.Timeout import java.util.concurrent.TimeUnit @Timeout(5) -class ApacheHttpClientResponseHandlerTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0 { +class ApacheHttpClientResponseHandlerTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0 { @Shared def client = HttpClients.custom() diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy index 18438e9e4df..629cfa8a790 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.apachehttpclient5.ApacheHttpClientDecorator import org.apache.hc.client5.http.config.RequestConfig @@ -16,7 +16,7 @@ import spock.lang.Timeout import java.util.concurrent.TimeUnit -abstract class ApacheHttpClientTest extends HttpClientTest implements TestingGenericHttpNamingConventions.ClientV0 { +abstract class ApacheHttpClientTest extends HttpClientTest2 implements TestingGenericHttpNamingConventions.ClientV0 { @Shared def client = HttpClients.custom() diff --git a/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy b/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy index 3a492b30885..f34eb682808 100644 --- a/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy @@ -7,7 +7,7 @@ import com.ning.http.client.Request import com.ning.http.client.RequestBuilder import com.ning.http.client.Response import com.ning.http.client.uri.Uri -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import datadog.trace.instrumentation.grizzly.client.ClientDecorator import spock.lang.AutoCleanup @@ -15,7 +15,7 @@ import spock.lang.Shared import java.util.concurrent.Executors -abstract class GrizzlyAsyncHttpClientTest extends HttpClientTest { +abstract class GrizzlyAsyncHttpClientTest extends HttpClientTest2 { @AutoCleanup @Shared diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy index 0556d94f1bf..42995633052 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest +import datadog.trace.agent.test.base.HttpClientTest2 import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import org.eclipse.jetty.client.HttpClient import org.eclipse.jetty.client.HttpProxy @@ -13,7 +13,7 @@ import spock.lang.Subject import java.util.concurrent.ExecutionException -abstract class JettyClientTest extends HttpClientTest { +abstract class JettyClientTest extends HttpClientTest2 { @Shared @Subject From 51b4adfbc81fe9c9a6b047f958ee715278277379 Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 11:22:21 -0600 Subject: [PATCH 3/9] Change headers struct to be List> instead of a map --- .../AkkaHttpClientInstrumentationTest.groovy | 4 +- .../AkkaHttpClientInstrumentationTest.groovy | 4 +- .../ApacheHttpAsyncClientCallbackTest.groovy | 6 +-- ...acheHttpAsyncClientNullCallbackTest.groovy | 6 +-- .../groovy/ApacheHttpAsyncClientTest.groovy | 6 +-- ...ApacheHttpClientResponseHandlerTest.groovy | 6 +-- .../test/groovy/ApacheHttpClientTest.groovy | 6 +-- .../groovy/ApacheHttpAsyncClient5Test.groovy | 4 +- ...ApacheHttpClientResponseHandlerTest.groovy | 6 +-- .../test/groovy/ApacheHttpClientTest.groovy | 6 +-- .../test/groovy/CommonsHttpClientTest.groovy | 4 +- .../AbstractGoogleHttpClientTest.groovy | 8 ++-- .../groovy/GrizzlyAsyncHttpClientTest.groovy | 6 +-- .../HttpUrlConnectionConnectFirstTest.groovy | 4 +- ...tpUrlConnectionResponseCodeOnlyTest.groovy | 4 +- .../test/groovy/HttpUrlConnectionTest.groovy | 4 +- ...HttpUrlConnectionUseCachesFalseTest.groovy | 4 +- .../test/groovy/SpringRestTemplateTest.groovy | 4 +- .../httpclient/JavaHttpClientAsyncTest.groovy | 4 +- .../httpclient/JavaHttpClientTest.groovy | 4 +- .../src/test/groovy/JaxRsClientV1Test.groovy | 4 +- .../test/groovy/JaxRsClientAsyncTest.groovy | 4 +- .../src/test/groovy/JaxRsClientTest.groovy | 4 +- .../src/test/groovy/JettyClientTest.groovy | 6 +-- .../src/test/groovy/JettyClientTest.groovy | 6 +-- .../src/test/groovy/JettyClientTest.groovy | 6 +-- .../latestdep/Netty38ClientTest.groovy | 4 +- .../netty38/Netty38ClientTest.groovy | 4 +- .../src/test/groovy/Netty40ClientTest.groovy | 4 +- .../src/test/groovy/Netty41ClientTest.groovy | 4 +- .../src/test/groovy/ReactorNettyTest.groovy | 4 +- .../src/test/groovy/HeadersUtil.groovy | 8 ++-- .../src/test/groovy/OkHttp2AsyncTest.groovy | 2 +- .../src/test/groovy/OkHttp2Test.groovy | 2 +- .../src/test/groovy/OkHttp3AsyncTest.groovy | 15 +++++++- .../src/test/groovy/OkHttp3Test.groovy | 17 +++++++-- .../PekkoHttpClientInstrumentationTest.groovy | 4 +- .../test/client/PlayWSClientTest.groovy | 6 +-- .../play25/client/PlayWSClientTest.groovy | 6 +-- .../src/test/groovy/PlayWSClientTest.groovy | 38 +++++++++++++++---- .../src/test/groovy/PlayWSClientTest.groovy | 38 +++++++++++++++---- .../src/test/groovy/PlayWSClientTest.groovy | 38 +++++++++++++++---- .../client/RatpackForkedHttpClientTest.groovy | 6 +-- .../client/RatpackHttpClientTest.groovy | 6 +-- .../groovy/ReactorNettyHttpClientTest.groovy | 6 +-- .../client/SpringWebfluxHttpClientBase.groovy | 4 +- ...bfluxHttpClientDoAfterTerminateTest.groovy | 4 +- ...luxHttpClientDoOnSuccessOrErrorTest.groovy | 4 +- ...ingWebfluxHttpClientDoOnSuccessTest.groovy | 4 +- ...gWebfluxHttpClientDoOnTerminateTest.groovy | 4 +- .../client/SpringWebfluxHttpClientBase.groovy | 6 +-- ...bfluxHttpClientDoAfterTerminateTest.groovy | 6 +-- ...luxHttpClientDoOnSuccessOrErrorTest.groovy | 6 +-- ...ingWebfluxHttpClientDoOnSuccessTest.groovy | 6 +-- ...gWebfluxHttpClientDoOnTerminateTest.groovy | 4 +- ...RxCircuitBreakerWebClientForkedTest.groovy | 4 +- .../client/VertxRxWebClientForkedTest.groovy | 4 +- .../client/VertxHttpClientForkedTest.groovy | 4 +- .../client/VertxHttpClientForkedTest.groovy | 6 +-- .../agent/test/base/HttpClientTest.groovy | 16 ++++---- 60 files changed, 244 insertions(+), 180 deletions(-) diff --git a/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/baseTest/groovy/AkkaHttpClientInstrumentationTest.groovy b/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/baseTest/groovy/AkkaHttpClientInstrumentationTest.groovy index 6ae3c72deaf..4c12e860890 100644 --- a/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/baseTest/groovy/AkkaHttpClientInstrumentationTest.groovy +++ b/dd-java-agent/instrumentation/akka-http/akka-http-10.0/src/baseTest/groovy/AkkaHttpClientInstrumentationTest.groovy @@ -36,10 +36,10 @@ abstract class AkkaHttpClientInstrumentationTest extends HttpClientTest { abstract CompletionStage doRequest(HttpRequest request) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = HttpRequest.create(uri.toString()) .withMethod(HttpMethods.lookup(method).get()) - .addHeaders(headers.collect { RawHeader.create(it.key, it.value) }) + .addHeaders(headers.collect { RawHeader.create(it[0], it[1]) }) def response try { diff --git a/dd-java-agent/instrumentation/akka-http/akka-http-10.6/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy b/dd-java-agent/instrumentation/akka-http/akka-http-10.6/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy index 7d4513b5570..e766994f54b 100644 --- a/dd-java-agent/instrumentation/akka-http/akka-http-10.6/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy +++ b/dd-java-agent/instrumentation/akka-http/akka-http-10.6/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy @@ -25,10 +25,10 @@ abstract class AkkaHttpClientInstrumentationTest extends HttpClientTest { abstract CompletionStage doRequest(HttpRequest request) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = HttpRequest.create(uri.toString()) .withMethod(HttpMethods.lookup(method).get()) - .addHeaders(headers.collect { RawHeader.create(it.key, it.value) }) + .addHeaders(headers.collect { RawHeader.create(it[0], it[1]) }) def response try { diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy index 41e312bdfa7..081c7ff0daa 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientCallbackTest.groovy @@ -31,11 +31,9 @@ class ApacheHttpAsyncClientCallbackTest extends HttpClientTest2 implements Testi } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = new HttpUriRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } def responseFuture = new CompletableFuture<>() diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy index 2067e026d30..85598067cb9 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientNullCallbackTest.groovy @@ -28,11 +28,9 @@ class ApacheHttpAsyncClientNullCallbackTest extends HttpClientTest2 implements T } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = new HttpUriRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } // The point here is to test case when callback is null - fire-and-forget style // So to make sure request is done we start request, wait for future to finish diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy index 7607412c99c..12c128a6928 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/test/groovy/ApacheHttpAsyncClientTest.groovy @@ -41,11 +41,9 @@ abstract class ApacheHttpAsyncClientTest extends HttpClientTest2 { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = createRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } def latch = new CountDownLatch(callback == null ? 0 : 1) diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy index 67c661b4e83..13261b8ecb4 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy @@ -31,11 +31,9 @@ class ApacheHttpClientResponseHandlerTest extends HttpClientTest2 implements Tes } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = new HttpUriRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } def status = client.execute(request, handler) diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy index 8ae0778bade..c68e7ef4258 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/test/groovy/ApacheHttpClientTest.groovy @@ -29,11 +29,9 @@ abstract class ApacheHttpClientTest extends HttpClientTes } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = createRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } def response = executeRequest(request, uri) callback?.call() diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy index 0ca2e5fb456..8490dc45e3a 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpAsyncClient5Test.groovy @@ -45,10 +45,10 @@ abstract class ApacheHttpAsyncClient5Test extends HttpCli } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = SimpleHttpRequests.create(method, uri) request.setConfig(RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS).build()) - headers.each { request.addHeader(it.key, it.value) } + headers.each { request.addHeader(it[0], it[1]) } def future = client.execute(request, null) def response = future.get(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS) diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy index d42441d2a8f..be5a279cc70 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientResponseHandlerTest.groovy @@ -38,11 +38,9 @@ class ApacheHttpClientResponseHandlerTest extends HttpClientTest2 implements Tes } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = new BasicClassicHttpRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } CloseableHttpResponse response = null def status = client.execute(request, handler) diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy index 629cfa8a790..7980d2b7942 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/test/groovy/ApacheHttpClientTest.groovy @@ -31,11 +31,9 @@ abstract class ApacheHttpClientTest extends HttpClientTes } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = createRequest(method, uri) - headers.entrySet().each { - request.addHeader(new BasicHeader(it.key, it.value)) - } + headers.each { request.addHeader(new BasicHeader(it[0], it[1])) } CloseableHttpResponse response = null try { diff --git a/dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy b/dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy index 23ded9aa8b0..6c997634787 100644 --- a/dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/commons-httpclient-2/src/test/groovy/CommonsHttpClientTest.groovy @@ -24,7 +24,7 @@ abstract class CommonsHttpClientTest extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpMethod httpMethod switch (method) { @@ -53,7 +53,7 @@ abstract class CommonsHttpClientTest extends HttpClientTest { throw new RuntimeException("Unsupported method: " + method) } - headers.each { httpMethod.setRequestHeader(it.key, it.value) } + headers.each { httpMethod.setRequestHeader(it[0], it[1]) } try { client.executeMethod(httpMethod) diff --git a/dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy b/dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy index 5f917d9a5aa..610ff97258e 100644 --- a/dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/google-http-client/src/test/groovy/AbstractGoogleHttpClientTest.groovy @@ -12,11 +12,11 @@ abstract class AbstractGoogleHttpClientTest extends HttpClientTest { def requestFactory = new NetHttpTransport().createRequestFactory() @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { doRequest(method, uri, headers, callback, false) } - int doRequest(String method, URI uri, Map headers, Closure callback, boolean throwExceptionOnError) { + int doRequest(String method, URI uri, List> headers, Closure callback, boolean throwExceptionOnError) { GenericUrl genericUrl = new GenericUrl(uri) HttpRequest request = requestFactory.buildRequest(method, genericUrl, null) @@ -26,8 +26,8 @@ abstract class AbstractGoogleHttpClientTest extends HttpClientTest { // GenericData::putAll method converts all known http headers to List // and lowercase all other headers def ci = request.getHeaders().getClassInfo() - request.getHeaders().putAll(headers.collectEntries { name, value -> - [(name): (ci.getFieldInfo(name) != null ? [value]: value.toLowerCase())] + request.getHeaders().putAll(headers.collectEntries { header -> + [(header[0]): (ci.getFieldInfo(header[0]) != null ? [header[1]]: header[1].toLowerCase())] }) request.setThrowExceptionOnExecuteError(throwExceptionOnError) diff --git a/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy b/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy index f34eb682808..145e34386da 100644 --- a/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/grizzly-client-1.9/src/test/groovy/GrizzlyAsyncHttpClientTest.groovy @@ -29,13 +29,11 @@ abstract class GrizzlyAsyncHttpClientTest extends HttpClientTest2 { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { RequestBuilder requestBuilder = new RequestBuilder(method) .setUri(Uri.create(uri.toString())) - headers.entrySet().each { - requestBuilder.addHeader(it.key, it.value) - } + headers.each { requestBuilder.addHeader(it[0], it[1]) } Request request = requestBuilder.build() def handler = new AsyncHandlerMock(callback) diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionConnectFirstTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionConnectFirstTest.groovy index 33d690c5719..2823a0a31eb 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionConnectFirstTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionConnectFirstTest.groovy @@ -7,11 +7,11 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScop class HttpUrlConnectionConnectFirstTest extends HttpUrlConnectionTest implements TestingGenericHttpNamingConventions.ClientV0{ @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpURLConnection connection = uri.toURL().openConnection() try { connection.setRequestMethod(method) - headers.each { connection.setRequestProperty(it.key, it.value) } + headers.each { connection.setRequestProperty(it[0], it[1]) } connection.setRequestProperty("Connection", "close") connection.connectTimeout = CONNECT_TIMEOUT_MS connection.readTimeout = READ_TIMEOUT_MS diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy index 5f1e580872b..6f2ed77088d 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionResponseCodeOnlyTest.groovy @@ -5,13 +5,13 @@ import spock.lang.Timeout class HttpUrlConnectionResponseCodeOnlyTest extends HttpUrlConnectionTest implements TestingGenericHttpNamingConventions.ClientV0 { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpURLConnection connection = uri.toURL().openConnection() try { connection.setRequestMethod(method) connection.connectTimeout = CONNECT_TIMEOUT_MS connection.readTimeout = READ_TIMEOUT_MS - headers.each { connection.setRequestProperty(it.key, it.value) } + headers.each { connection.setRequestProperty(it[0], it[1]) } connection.setRequestProperty("Connection", "close") return connection.getResponseCode() } finally { diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy index 88b88238e2e..2fae8238b02 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy @@ -19,11 +19,11 @@ abstract class HttpUrlConnectionTest extends HttpClientTest { static final STATUS = 200 @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpURLConnection connection = uri.toURL().openConnection() try { connection.setRequestMethod(method) - headers.each { connection.setRequestProperty(it.key, it.value) } + headers.each { connection.setRequestProperty(it[0], it[1]) } connection.setRequestProperty("Connection", "close") connection.useCaches = true connection.connectTimeout = CONNECT_TIMEOUT_MS diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy index 9412528b8f7..f54c1b9805d 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionUseCachesFalseTest.groovy @@ -7,11 +7,11 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScop class HttpUrlConnectionUseCachesFalseTest extends HttpUrlConnectionTest implements TestingGenericHttpNamingConventions.ClientV0 { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpURLConnection connection = uri.toURL().openConnection() try { connection.setRequestMethod(method) - headers.each { connection.setRequestProperty(it.key, it.value) } + headers.each { connection.setRequestProperty(it[0], it[1]) } connection.setRequestProperty("Connection", "close") connection.useCaches = false connection.connectTimeout = CONNECT_TIMEOUT_MS diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy index c34ac5c4eed..45c88dc550a 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/SpringRestTemplateTest.groovy @@ -27,9 +27,9 @@ abstract class SpringRestTemplateTest extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def httpHeaders = new HttpHeaders() - headers.each { httpHeaders.put(it.key, [it.value]) } + headers.each { httpHeaders.put(it[0], [it[1]]) } def request = new HttpEntity(httpHeaders) try { ResponseEntity response = restTemplate.exchange(uri, HttpMethod.resolve(method), request, String) diff --git a/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientAsyncTest.groovy b/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientAsyncTest.groovy index 07750123db6..fb1d3255cc7 100644 --- a/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientAsyncTest.groovy +++ b/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientAsyncTest.groovy @@ -5,12 +5,12 @@ import java.net.http.HttpResponse class JavaHttpClientAsyncTest extends JavaHttpClientTest { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = HttpRequest.newBuilder() .uri(uri) .method(method, HttpRequest.BodyPublishers.ofString(body)) if (headers != null) { - headers.each { key, value -> request.header(key, value) } + headers.each { request.header(it[0], it[1]) } } def response = client.sendAsync(request.build(), HttpResponse.BodyHandlers.discarding()) diff --git a/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientTest.groovy b/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientTest.groovy index 66813e4757e..267d60f8402 100644 --- a/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/java-http-client/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientTest.groovy @@ -20,12 +20,12 @@ abstract class JavaHttpClientTest extends HttpClientTest { .build() @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = HttpRequest.newBuilder() .uri(uri) .method(method, HttpRequest.BodyPublishers.ofString(body)) if (headers != null) { - headers.each { key, value -> request.header(key, value) } + headers.each { request.header(it[0], it[1]) } } def response = client.send(request.build(), HttpResponse.BodyHandlers.discarding()) diff --git a/dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy b/dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy index 9244f3f22c4..b208ff08b07 100644 --- a/dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy +++ b/dd-java-agent/instrumentation/jax-rs-client-1.1/src/test/groovy/JaxRsClientV1Test.groovy @@ -22,9 +22,9 @@ abstract class JaxRsClientV1Test extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def resource = client.resource(uri).requestBuilder - headers.each { resource.header(it.key, it.value) } + headers.each { resource.header(it[0], it[1]) } def reqBody = BODY_METHODS.contains(method) ? body : null ClientResponse response = resource.method(method, ClientResponse, reqBody) callback?.call() diff --git a/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy b/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy index 1ce82df6e34..812355358ca 100644 --- a/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy +++ b/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientAsyncTest.groovy @@ -21,11 +21,11 @@ abstract class JaxRsClientAsyncTest extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { Client client = builder().build() WebTarget service = client.target(uri) def builder = service.request(MediaType.TEXT_PLAIN) - headers.each { builder.header(it.key, it.value) } + headers.each { builder.header(it[0], it[1]) } AsyncInvoker request = builder.async() def latch = new CountDownLatch(1) diff --git a/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy b/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy index f7f83cb4ace..0004804b233 100644 --- a/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy +++ b/dd-java-agent/instrumentation/jax-rs-client-2.0/src/test/groovy/JaxRsClientTest.groovy @@ -24,12 +24,12 @@ import java.util.concurrent.TimeUnit abstract class JaxRsClientTest extends HttpClientTest { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { Client client = builder().build() WebTarget service = client.target(uri) Invocation.Builder request = service.request(MediaType.TEXT_PLAIN) - headers.each { request.header(it.key, it.value) } + headers.each { request.header(it[0], it[1]) } def reqBody = BODY_METHODS.contains(method) ? Entity.text(body) : null Response response = request.method(method, (Entity) reqBody) callback?.call() diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/test/groovy/JettyClientTest.groovy b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/test/groovy/JettyClientTest.groovy index 4b4cf055765..3cce43efe08 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/test/groovy/JettyClientTest.groovy +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/test/groovy/JettyClientTest.groovy @@ -45,12 +45,10 @@ abstract class JettyClientTest extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def proxy = uri.fragment != null && uri.fragment.equals("proxy") Request req = (proxy ? proxiedClient : client).newRequest(uri).method(method) - headers.entrySet().each { - req.header(it.key, it.value) - } + headers.each { req.header(it[0], it[1]) } if (body) { req.content(new StringContentProvider(body)) } diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-12.0/src/test/groovy/JettyClientTest.groovy b/dd-java-agent/instrumentation/jetty-client/jetty-client-12.0/src/test/groovy/JettyClientTest.groovy index 41aa79f1a94..1fd7eaab08f 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-12.0/src/test/groovy/JettyClientTest.groovy +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-12.0/src/test/groovy/JettyClientTest.groovy @@ -45,11 +45,11 @@ abstract class JettyClientTest extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def proxy = uri.fragment != null && uri.fragment.equals("proxy") Request req = (proxy ? proxiedClient : client).newRequest(uri).method(method) - headers.entrySet().each { h -> - req.headers {it.add(h.key, h.value)} + headers.each { h -> + req.headers {it.add(h[0], h[1])} } if (body) { req.body(new StringRequestContent(body)) diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy index 42995633052..aa97c8be1a4 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy @@ -38,12 +38,10 @@ abstract class JettyClientTest extends HttpClientTest2 { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def proxy = uri.fragment != null && uri.fragment.equals("proxy") Request req = (proxy ? proxiedClient : client).newRequest(uri).method(method) - headers.entrySet().each { - req.header(it.key, it.value) - } + headers.each { req.header(it[0], it[1]) } if (body) { req.content(new StringContentProvider(body)) } diff --git a/dd-java-agent/instrumentation/netty-3.8/src/latestDepTest/groovy/datadog/trace/instrumentation/netty38/latestdep/Netty38ClientTest.groovy b/dd-java-agent/instrumentation/netty-3.8/src/latestDepTest/groovy/datadog/trace/instrumentation/netty38/latestdep/Netty38ClientTest.groovy index c01b896ed25..8ccbaa10190 100644 --- a/dd-java-agent/instrumentation/netty-3.8/src/latestDepTest/groovy/datadog/trace/instrumentation/netty38/latestdep/Netty38ClientTest.groovy +++ b/dd-java-agent/instrumentation/netty-3.8/src/latestDepTest/groovy/datadog/trace/instrumentation/netty38/latestdep/Netty38ClientTest.groovy @@ -31,10 +31,10 @@ abstract class Netty38ClientTest extends HttpClientTest { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(clientConfig) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def methodName = "prepare" + method.toLowerCase().capitalize() def requestBuilder = asyncHttpClient."$methodName"(uri.toString()) - headers.each { requestBuilder.setHeader(it.key, it.value) } + headers.each { requestBuilder.setHeader(it[0], it[1]) } def response = requestBuilder.execute(new AsyncCompletionHandler() { @Override Object onCompleted(Response response) throws Exception { diff --git a/dd-java-agent/instrumentation/netty-3.8/src/test/groovy/datadog/trace/instrumentation/netty38/Netty38ClientTest.groovy b/dd-java-agent/instrumentation/netty-3.8/src/test/groovy/datadog/trace/instrumentation/netty38/Netty38ClientTest.groovy index 16980c2a778..85ca2f41293 100644 --- a/dd-java-agent/instrumentation/netty-3.8/src/test/groovy/datadog/trace/instrumentation/netty38/Netty38ClientTest.groovy +++ b/dd-java-agent/instrumentation/netty-3.8/src/test/groovy/datadog/trace/instrumentation/netty38/Netty38ClientTest.groovy @@ -36,10 +36,10 @@ abstract class Netty38ClientTest extends HttpClientTest { AsyncHttpClient asyncHttpClient = new AsyncHttpClient(clientConfig) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def methodName = "prepare" + method.toLowerCase().capitalize() def requestBuilder = asyncHttpClient."$methodName"(uri.toString()) - headers.each { requestBuilder.setHeader(it.key, it.value) } + headers.each { requestBuilder.setHeader(it[0], it[1]) } def response = requestBuilder.execute(new AsyncCompletionHandler() { @Override Object onCompleted(Response response) throws Exception { diff --git a/dd-java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy b/dd-java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy index 313039cbbd5..fb7723578cc 100644 --- a/dd-java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy +++ b/dd-java-agent/instrumentation/netty-4.0/src/test/groovy/Netty40ClientTest.groovy @@ -50,12 +50,12 @@ abstract class Netty40ClientTest extends HttpClientTest { .setProxyServer(new ProxyServer.Builder("localhost", proxy.port).build())) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def proxy = uri.fragment != null && uri.fragment.equals("proxy") def client = proxy ? proxiedAsyncHttpClient : asyncHttpClient def methodName = "prepare" + method.toLowerCase().capitalize() BoundRequestBuilder requestBuilder = client."$methodName"(uri.toString()) - headers.each { requestBuilder.setHeader(it.key, it.value) } + headers.each { requestBuilder.setHeader(it[0], it[1]) } requestBuilder.setBody(body) def response = requestBuilder.execute(new AsyncCompletionHandler() { @Override diff --git a/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/Netty41ClientTest.groovy b/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/Netty41ClientTest.groovy index 860bc6b5f8e..efe79d08d0d 100644 --- a/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/Netty41ClientTest.groovy +++ b/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/Netty41ClientTest.groovy @@ -46,12 +46,12 @@ abstract class Netty41ClientTest extends HttpClientTest { .setProxyServer(new ProxyServer.Builder("localhost", proxy.port).build())) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def proxy = uri.fragment != null && uri.fragment.equals("proxy") def client = proxy ? proxiedAsyncHttpClient : asyncHttpClient def methodName = "prepare" + method.toLowerCase().capitalize() BoundRequestBuilder requestBuilder = client."$methodName"(uri.toString()) - headers.each { requestBuilder.setHeader(it.key, it.value) } + headers.each { requestBuilder.setHeader(it[0], it[1]) } requestBuilder.setBody(body) def response = requestBuilder.execute(new AsyncCompletionHandler() { @Override diff --git a/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/ReactorNettyTest.groovy b/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/ReactorNettyTest.groovy index 0cdc7d5f2de..58e4f9d6f13 100644 --- a/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/ReactorNettyTest.groovy +++ b/dd-java-agent/instrumentation/netty-4.1/src/test/groovy/ReactorNettyTest.groovy @@ -59,13 +59,13 @@ class ReactorNettyTest extends HttpClientTest implements TestingNettyHttpNamingC } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { HttpClientResponse resp = HttpClient.create() .doAfterRequest({ r, c -> c.addHandler("TimeoutHandler", new ReadTimeoutHandler(READ_TIMEOUT_MS, TimeUnit.MILLISECONDS)) }) .baseUrl(server.address.toString()) .headers { headers.each { h -> - it.set(h.key, h.value) + it.set(h[0], h[1]) } } .request(HttpMethod.valueOf(method)) diff --git a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/HeadersUtil.groovy b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/HeadersUtil.groovy index 5940d375211..4bd13a6fb66 100644 --- a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/HeadersUtil.groovy +++ b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/HeadersUtil.groovy @@ -1,9 +1,9 @@ class HeadersUtil { - static headersToArray(Map headers) { + static headersToArray(List> headers) { String[] headersArr = new String[headers.size() * 2] - headers.eachWithIndex { k, v, i -> - headersArr[i] = k - headersArr[i + 1] = v + headers.eachWithIndex { header, i -> + headersArr[i] = header[0] + headersArr[i + 1] = header[1] } headersArr diff --git a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy index c2ae5c06a6f..d800ef19c14 100644 --- a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy +++ b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy @@ -17,7 +17,7 @@ abstract class OkHttp2AsyncTest extends OkHttp2Test { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def reqBody = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), body) : null def request = new Request.Builder() .url(uri.toURL()) diff --git a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2Test.groovy b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2Test.groovy index 5476112fa10..84d8397bd40 100644 --- a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2Test.groovy +++ b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2Test.groovy @@ -25,7 +25,7 @@ abstract class OkHttp2Test extends HttpClientTest { } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def reqBody = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), body) : null def request = new Request.Builder() diff --git a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy index 335c778bf7b..cc7ded34d8e 100644 --- a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy +++ b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy @@ -17,12 +17,23 @@ import static java.util.concurrent.TimeUnit.SECONDS abstract class OkHttp3AsyncTest extends OkHttp3Test { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def reqBody = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), body) : null + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } def request = new Request.Builder() .url(uri.toURL()) .method(method, reqBody) - .headers(Headers.of(headers)) + .headers(Headers.of(headersMap)) .build() AtomicReference responseRef = new AtomicReference() diff --git a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy index eb7af3fe476..70cb47f8314 100644 --- a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy +++ b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy @@ -35,12 +35,23 @@ abstract class OkHttp3Test extends HttpClientTest { .build() @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def reqBody = HttpMethod.requiresRequestBody(method) ? RequestBody.create(MediaType.parse("text/plain"), body) : null + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } def request = new Request.Builder() .url(uri.toURL()) .method(method, reqBody) - .headers(Headers.of(headers)).build() + .headers(Headers.of(headersMap)).build() def response = client.newCall(request).execute() callback?.call() return response.code() @@ -58,7 +69,7 @@ abstract class OkHttp3Test extends HttpClientTest { def "request to agent not traced"() { when: - def status = doRequest(method, url, ["Datadog-Meta-Lang": "java"]) + def status = doRequest(method, url, [["Datadog-Meta-Lang", "java"]]) then: status == 200 diff --git a/dd-java-agent/instrumentation/pekko-http-1.0/src/baseTest/groovy/PekkoHttpClientInstrumentationTest.groovy b/dd-java-agent/instrumentation/pekko-http-1.0/src/baseTest/groovy/PekkoHttpClientInstrumentationTest.groovy index a8d38623d1d..d6125feef33 100644 --- a/dd-java-agent/instrumentation/pekko-http-1.0/src/baseTest/groovy/PekkoHttpClientInstrumentationTest.groovy +++ b/dd-java-agent/instrumentation/pekko-http-1.0/src/baseTest/groovy/PekkoHttpClientInstrumentationTest.groovy @@ -25,10 +25,10 @@ abstract class PekkoHttpClientInstrumentationTest extends HttpClientTest { abstract CompletionStage doRequest(HttpRequest request) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = HttpRequest.create(uri.toString()) .withMethod(HttpMethods.lookup(method).get()) - .addHeaders(headers.collect { RawHeader.create(it.key, it.value) }) + .addHeaders(headers.collect { RawHeader.create(it[0], it[1]) }) def response try { diff --git a/dd-java-agent/instrumentation/play-2.3/src/test/groovy/datadog/trace/instrumentation/play23/test/client/PlayWSClientTest.groovy b/dd-java-agent/instrumentation/play-2.3/src/test/groovy/datadog/trace/instrumentation/play23/test/client/PlayWSClientTest.groovy index 29233c42076..6fa17faea1b 100644 --- a/dd-java-agent/instrumentation/play-2.3/src/test/groovy/datadog/trace/instrumentation/play23/test/client/PlayWSClientTest.groovy +++ b/dd-java-agent/instrumentation/play-2.3/src/test/groovy/datadog/trace/instrumentation/play23/test/client/PlayWSClientTest.groovy @@ -37,11 +37,9 @@ class PlayWSClientTest extends HttpClientTest implements TestingNettyHttpNamingC } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = client.url(uri.toString()) - headers.entrySet().each { - request.setHeader(it.key, it.value) - } + headers.each { request.setHeader(it[0], it[1]) } def status = request.execute(method).map({ callback?.call() diff --git a/dd-java-agent/instrumentation/play-2.4/src/test/groovy/datadog/trace/instrumentation/play25/client/PlayWSClientTest.groovy b/dd-java-agent/instrumentation/play-2.4/src/test/groovy/datadog/trace/instrumentation/play25/client/PlayWSClientTest.groovy index 2e500fe2f93..24d2df55ffa 100644 --- a/dd-java-agent/instrumentation/play-2.4/src/test/groovy/datadog/trace/instrumentation/play25/client/PlayWSClientTest.groovy +++ b/dd-java-agent/instrumentation/play-2.4/src/test/groovy/datadog/trace/instrumentation/play25/client/PlayWSClientTest.groovy @@ -18,11 +18,9 @@ abstract class PlayWSClientTest extends HttpClientTest { def client = WS.newClient(-1) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = client.url(uri.toString()) - headers.entrySet().each { - request.setHeader(it.key, it.value) - } + headers.each { request.setHeader(it[0], it[1]) } def status = request.execute(method).thenApply { callback?.call() diff --git a/dd-java-agent/instrumentation/play-ws-1/src/test/groovy/PlayWSClientTest.groovy b/dd-java-agent/instrumentation/play-ws-1/src/test/groovy/PlayWSClientTest.groovy index aa32625dde6..692a21e2357 100644 --- a/dd-java-agent/instrumentation/play-ws-1/src/test/groovy/PlayWSClientTest.groovy +++ b/dd-java-agent/instrumentation/play-ws-1/src/test/groovy/PlayWSClientTest.groovy @@ -18,10 +18,10 @@ abstract class PlayJavaWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).execute() .whenComplete({ response, throwable -> callback?.call() @@ -45,10 +45,10 @@ class PlayJavaStreamedWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).stream() .whenComplete({ response, throwable -> callback?.call() @@ -75,11 +75,22 @@ class PlayScalaWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .execute() .transform({ theTry -> callback?.call() @@ -106,11 +117,22 @@ class PlayScalaStreamedWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .stream() .transform({ theTry -> callback?.call() diff --git a/dd-java-agent/instrumentation/play-ws-2.1/src/test/groovy/PlayWSClientTest.groovy b/dd-java-agent/instrumentation/play-ws-2.1/src/test/groovy/PlayWSClientTest.groovy index 8e2137991f9..dc3d262a69a 100644 --- a/dd-java-agent/instrumentation/play-ws-2.1/src/test/groovy/PlayWSClientTest.groovy +++ b/dd-java-agent/instrumentation/play-ws-2.1/src/test/groovy/PlayWSClientTest.groovy @@ -16,10 +16,10 @@ class PlayJavaWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).execute() .whenComplete({ response, throwable -> callback?.call() @@ -42,10 +42,10 @@ class PlayJavaStreamedWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).stream() .whenComplete({ response, throwable -> callback?.call() @@ -71,11 +71,22 @@ class PlayScalaWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .execute() .transform({ theTry -> callback?.call() @@ -101,11 +112,22 @@ class PlayScalaStreamedWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .stream() .transform({ theTry -> callback?.call() diff --git a/dd-java-agent/instrumentation/play-ws-2/src/test/groovy/PlayWSClientTest.groovy b/dd-java-agent/instrumentation/play-ws-2/src/test/groovy/PlayWSClientTest.groovy index b2f002ede91..46766dc214e 100644 --- a/dd-java-agent/instrumentation/play-ws-2/src/test/groovy/PlayWSClientTest.groovy +++ b/dd-java-agent/instrumentation/play-ws-2/src/test/groovy/PlayWSClientTest.groovy @@ -17,10 +17,10 @@ abstract class PlayJavaWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).execute() .whenComplete({ response, throwable -> callback?.call() @@ -43,10 +43,10 @@ class PlayJavaStreamedWSClientTest extends PlayWSClientTestBase { StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { StandaloneWSRequest wsRequest = wsClient.url(uri.toURL().toString()).setFollowRedirects(true) - headers.entrySet().each { entry -> wsRequest.addHeader(entry.getKey(), entry.getValue()) } + headers.each { wsRequest.addHeader(it[0], it[1]) } StandaloneWSResponse wsResponse = wsRequest.setMethod(method).stream() .whenComplete({ response, throwable -> callback?.call() @@ -72,11 +72,22 @@ class PlayScalaWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .execute() .transform({ theTry -> callback?.call() @@ -102,11 +113,22 @@ class PlayScalaStreamedWSClientTest extends PlayWSClientTestBase { play.api.libs.ws.StandaloneWSClient wsClient @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { + Map headersMap = new HashMap<>() + for (List header : headers) { + String key = header[0] + String val = header[1] + if (headersMap.containsKey(key)) { + String originalVal = headersMap.get(key) + headersMap.put(key, originalVal + "," + val) + } else { + headersMap.put(key, val) + } + } Future futureResponse = wsClient.url(uri.toURL().toString()) .withMethod(method) .withFollowRedirects(true) - .withHttpHeaders(JavaConverters.mapAsScalaMap(headers).toSeq()) + .withHttpHeaders(JavaConverters.mapAsScalaMap(headersMap).toSeq()) .stream() .transform({ theTry -> callback?.call() diff --git a/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackForkedHttpClientTest.groovy b/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackForkedHttpClientTest.groovy index ebd74ed5859..c682df8bd48 100644 --- a/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackForkedHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackForkedHttpClientTest.groovy @@ -6,13 +6,13 @@ import ratpack.exec.ExecResult class RatpackForkedHttpClientTest extends RatpackHttpClientTest { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { ExecResult result = exec.yield { def resp = client.request(uri) { spec -> spec.method(method) spec.headers { headersSpec -> - headers.entrySet().each { - headersSpec.add(it.key, it.value) + headers.each { + headersSpec.add(it[0], it[1]) } } } diff --git a/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackHttpClientTest.groovy b/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackHttpClientTest.groovy index cdc4130281b..e7cd453f0e7 100644 --- a/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/ratpack-1.5/src/test/groovy/client/RatpackHttpClientTest.groovy @@ -30,14 +30,14 @@ class RatpackHttpClientTest extends HttpClientTest implements TestingNettyHttpNa } @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { ExecResult result = exec.yield { def resp = client.request(uri) { spec -> spec.connectTimeout(Duration.ofSeconds(2)) spec.method(method) spec.headers { headersSpec -> - headers.entrySet().each { - headersSpec.add(it.key, it.value) + headers.each { + headersSpec.add(it[0], it[1]) } } } diff --git a/dd-java-agent/instrumentation/reactor-netty-1/src/test/groovy/ReactorNettyHttpClientTest.groovy b/dd-java-agent/instrumentation/reactor-netty-1/src/test/groovy/ReactorNettyHttpClientTest.groovy index c7c217344b3..544324fd4c2 100644 --- a/dd-java-agent/instrumentation/reactor-netty-1/src/test/groovy/ReactorNettyHttpClientTest.groovy +++ b/dd-java-agent/instrumentation/reactor-netty-1/src/test/groovy/ReactorNettyHttpClientTest.groovy @@ -25,11 +25,11 @@ class ReactorNettyHttpClientTest extends HttpClientTest implements TestingNettyH .disableRetry(true) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { httpClient - .headers({ hdrs -> + .headers({ h -> headers.each { - hdrs.set(it.key, it.value) + h.set(it[0], it[1]) } }) .request(HttpMethod.valueOf(method)) diff --git a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientBase.groovy b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientBase.groovy index 8c60fddbff3..111d46aac10 100644 --- a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientBase.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientBase.groovy @@ -32,12 +32,12 @@ abstract class SpringWebfluxHttpClientBase extends HttpClientTest implements Tes abstract void check() @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.resolve(method)) .uri(uri) - .headers { h -> headers.forEach({ key, value -> h.add(key, value) }) } + .headers { h -> headers.each({ h.add(it[0], it[1]) }) } .exchange() .doAfterSuccessOrError { res, ex -> callback?.call() diff --git a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy index c03f9a18082..a13ce89e1f5 100644 --- a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy @@ -11,12 +11,12 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoAfterTerminateTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.resolve(method)) .uri(uri) - .headers { h -> headers.forEach({ key, value -> h.add(key, value) }) } + .headers { h -> headers.each({ h.add(it[0], it[1]) }) } .exchange() .doAfterTerminate { runnable -> callback?.call() diff --git a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy index eb99848e9d5..8e5143f79ff 100644 --- a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy @@ -11,12 +11,12 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan abstract class SpringWebfluxHttpClientDoOnSuccessOrErrorTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.resolve(method)) .uri(uri) - .headers { h -> headers.forEach({ key, value -> h.add(key, value) }) } + .headers { h -> headers.each({ h.add(it[0], it[1]) }) } .exchange() .doOnSuccessOrError { res, err -> callback?.call() diff --git a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy index 82efca874c9..dd30196c208 100644 --- a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy @@ -11,12 +11,12 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoOnSuccessTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.resolve(method)) .uri(uri) - .headers { h -> headers.forEach({ key, value -> h.add(key, value) }) } + .headers { h -> headers.each({ h.add(it[0], it[1]) }) } .exchange() .doOnSuccess { res -> callback?.call() diff --git a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy index d7a0620dca9..c4d6367dbd2 100644 --- a/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-5/src/test/groovy/dd/trace/instrumentation/springwebflux/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy @@ -11,12 +11,12 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoOnTerminateTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.resolve(method)) .uri(uri) - .headers { h -> headers.forEach({ key, value -> h.add(key, value) }) } + .headers { h -> headers.each({ h.add(it[0], it[1]) }) } .exchange() .doOnTerminate { runnable -> callback?.call() diff --git a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientBase.groovy b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientBase.groovy index 0048091d901..c9da7cc7eee 100644 --- a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientBase.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientBase.groovy @@ -33,14 +33,14 @@ abstract class SpringWebfluxHttpClientBase extends HttpClientTest implements Tes abstract void check() @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.valueOf(method)) .uri(uri) .headers { - h -> headers.forEach({ - key, value -> h.add(key, value) + h -> headers.each({ + h.add(it[0], it[1]) }) } .exchangeToMono (Mono::just) diff --git a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy index 36adaa1b9c4..ef001409611 100644 --- a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoAfterTerminateTest.groovy @@ -12,14 +12,14 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoAfterTerminateTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.valueOf(method)) .uri(uri) .headers { - h -> headers.forEach({ - key, value -> h.add(key, value) + h -> headers.each({ + h.add(it[0], it[1]) }) } .exchangeToMono (Mono::just) diff --git a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy index 625d91084ec..2a8afec6b1f 100644 --- a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessOrErrorTest.groovy @@ -12,14 +12,14 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan abstract class SpringWebfluxHttpClientDoOnSuccessOrErrorTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.valueOf(method)) .uri(uri) .headers { - h -> headers.forEach({ - key, value -> h.add(key, value) + h -> headers.each({ + h.add(it[0], it[1]) }) } .exchangeToMono (Mono::just) diff --git a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy index be489e8a6fe..d0a91b63bf7 100644 --- a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnSuccessTest.groovy @@ -12,14 +12,14 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoOnSuccessTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.valueOf(method)) .uri(uri) .headers { - h -> headers.forEach({ - key, value -> h.add(key, value) + h -> headers.each({ + h.add(it[0], it[1]) }) } .exchangeToMono (Mono::just) diff --git a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy index c4dc5bd9d2f..f92daa7da8b 100644 --- a/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy +++ b/dd-java-agent/instrumentation/spring-webflux-6/src/test/groovy/dd/trace/instrumentation/springwebflux6/client/SpringWebfluxHttpClientDoOnTerminateTest.groovy @@ -12,14 +12,14 @@ import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan class SpringWebfluxHttpClientDoOnTerminateTest extends SpringWebfluxHttpClientBase { @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def hasParent = activeSpan() != null def client = createClient(component()) ClientResponse response = client.method(HttpMethod.valueOf(method)) .uri(uri) .headers { h -> headers.forEach({ - key, value -> h.add(key, value) + h.add(it[0], it[1]) }) } .exchangeToMono (Mono::just) diff --git a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxCircuitBreakerWebClientForkedTest.groovy b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxCircuitBreakerWebClientForkedTest.groovy index cb8361bffe5..23a9586da11 100644 --- a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxCircuitBreakerWebClientForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxCircuitBreakerWebClientForkedTest.groovy @@ -43,9 +43,9 @@ class VertxRxCircuitBreakerWebClientForkedTest extends HttpClientTest implements ) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } + headers.each { request.putHeader(it[0], it[1]) } def future = new CompletableFuture() diff --git a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxWebClientForkedTest.groovy b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxWebClientForkedTest.groovy index c79d43d1a30..9773709f966 100644 --- a/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxWebClientForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-rx-3.5/src/test/groovy/client/VertxRxWebClientForkedTest.groovy @@ -32,9 +32,9 @@ class VertxRxWebClientForkedTest extends HttpClientTest implements TestingNettyH WebClient client = WebClient.create(vertx, clientOptions) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { def request = client.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } + headers.each { request.putHeader(it[0], it[1]) } return request .rxSend() .doOnSuccess { response -> callback?.call() } diff --git a/dd-java-agent/instrumentation/vertx-web-3.4/src/test/groovy/client/VertxHttpClientForkedTest.groovy b/dd-java-agent/instrumentation/vertx-web-3.4/src/test/groovy/client/VertxHttpClientForkedTest.groovy index dd308077653..8fd88ea2685 100644 --- a/dd-java-agent/instrumentation/vertx-web-3.4/src/test/groovy/client/VertxHttpClientForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-web-3.4/src/test/groovy/client/VertxHttpClientForkedTest.groovy @@ -33,10 +33,10 @@ class VertxHttpClientForkedTest extends HttpClientTest implements TestingNettyHt def httpClient = vertx.createHttpClient(clientOptions) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { CompletableFuture future = new CompletableFuture<>() def request = httpClient.request(HttpMethod.valueOf(method), uri.port, uri.host, "$uri") - headers.each { request.putHeader(it.key, it.value) } + headers.each { request.putHeader(it[0], it[1]) } request.handler { response -> try { callback?.call() diff --git a/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy b/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy index b1a5ba3f1f4..7cd7e5fe293 100644 --- a/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy @@ -38,11 +38,11 @@ class VertxHttpClientForkedTest extends HttpClientTest implements TestingNettyHt def httpClient = vertx.createHttpClient(clientOptions) @Override - int doRequest(String method, URI uri, Map headers, String body, Closure callback) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback) { return doRequest(method, uri, headers, body, callback, -1) } - int doRequest(String method, URI uri, Map headers, String body, Closure callback, long timeout) { + int doRequest(String method, URI uri, List> headers, String body, Closure callback, long timeout) { CompletableFuture future = new CompletableFuture<>() RequestOptions requestOptions = new RequestOptions() @@ -54,7 +54,7 @@ class VertxHttpClientForkedTest extends HttpClientTest implements TestingNettyHt httpClient.request(requestOptions, { requestReadyToBeSend -> def request = requestReadyToBeSend.result() - headers.each { request.putHeader(it.key, it.value) } + headers.each { request.putHeader(it[0], it[1]) } request.send(body, { response -> try { callback?.call() diff --git a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy index 228db2cd8e3..9739ca69ca0 100644 --- a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy +++ b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/base/HttpClientTest.groovy @@ -142,7 +142,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { * @param method * @return */ - abstract int doRequest(String method, URI uri, Map headers = [:], String body = "", Closure callback = null) + abstract int doRequest(String method, URI uri, List> headers = [], String body = "", Closure callback = null) String keyStorePath() { server.keystorePath @@ -243,7 +243,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { when: def status = runUnderTrace("parent") { - doRequest(method, url, [:], body) + doRequest(method, url, [], body) } println("RESPONSE: $status") if (isDataStreamsEnabled()) { @@ -283,7 +283,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { def "basic #method request with parent"() { when: def status = runUnderTrace("parent") { - doRequest(method, server.address.resolve("/success"), [:], body) + doRequest(method, server.address.resolve("/success"), [], body) } if (isDataStreamsEnabled()) { TEST_DATA_STREAMS_WRITER.waitForGroups(1) @@ -426,7 +426,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { when: injectSysConfig(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "$renameService") def status = runUnderTrace("parent") { - doRequest(method, server.address.resolve("/success"), ["is-dd-server": "false"]) + doRequest(method, server.address.resolve("/success"), [["is-dd-server", "false"]]) } if (isDataStreamsEnabled()) { TEST_DATA_STREAMS_WRITER.waitForGroups(1) @@ -464,7 +464,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { when: def status = runUnderTrace("parent") { - doRequest(method, server.address.resolve("/success"), ["is-dd-server": "false"], "") { + doRequest(method, server.address.resolve("/success"), [["is-dd-server", "false"]], "") { runUnderTrace("child") { blockUntilChildSpansFinished(1) } @@ -498,7 +498,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { def "trace request with callback and no parent"() { when: - def status = doRequest(method, server.address.resolve("/success"), ["is-dd-server": "false"], "") { + def status = doRequest(method, server.address.resolve("/success"), [["is-dd-server", "false"]], "") { runUnderTrace("callback") { // FIXME: since in async we may not have the other trace report until the callback is done // we should add a test method to detect that the other trace is finished but waiting for @@ -650,7 +650,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { def uri = server.address.resolve("/to-secured") when: - def status = doRequest(method, uri, [(BASIC_AUTH_KEY): BASIC_AUTH_VAL]) + def status = doRequest(method, uri, [[BASIC_AUTH_KEY, BASIC_AUTH_VAL]]) if (isDataStreamsEnabled()) { TEST_DATA_STREAMS_WRITER.waitForGroups(1) } @@ -765,7 +765,7 @@ abstract class HttpClientTest extends VersionedNamingTestBase { def "test request header #header tag mapping"() { when: def url = server.address.resolve("/success") - def status = doRequest(method, url, [(header): value]) + def status = doRequest(method, url, [[header, value]]) if (isDataStreamsEnabled()) { TEST_DATA_STREAMS_WRITER.waitForGroups(1) } From 1c01394ddcef94715e96d0f36e55a3fc19cc7ea2 Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 11:23:04 -0600 Subject: [PATCH 4/9] Update HttpServletRequestExtractAdapter --- .../server/http/HttpServletRequestExtractAdapter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dd-java-agent/testing/src/main/java/datadog/trace/agent/test/server/http/HttpServletRequestExtractAdapter.java b/dd-java-agent/testing/src/main/java/datadog/trace/agent/test/server/http/HttpServletRequestExtractAdapter.java index 6f835ab619a..f737d977ddc 100644 --- a/dd-java-agent/testing/src/main/java/datadog/trace/agent/test/server/http/HttpServletRequestExtractAdapter.java +++ b/dd-java-agent/testing/src/main/java/datadog/trace/agent/test/server/http/HttpServletRequestExtractAdapter.java @@ -22,7 +22,15 @@ public void forEachKey( Enumeration headerNames = carrier.getHeaderNames(); while (headerNames.hasMoreElements()) { final String header = headerNames.nextElement(); - if (!classifier.accept(header, carrier.getHeader(header))) { + StringBuilder headerVals = new StringBuilder(); + Enumeration headers = carrier.getHeaders(header); + while (headers.hasMoreElements()) { + headerVals.append(headers.nextElement()); + if (headers.hasMoreElements()) { + headerVals.append(','); + } + } + if (!classifier.accept(header, headerVals.toString())) { return; } } From c7f8230fdba72f4a2146d738a9f97f53ba21e2c8 Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 11:26:03 -0600 Subject: [PATCH 5/9] Update HostAndRequestAsHttpUriRequest for Apaches --- .../HostAndRequestAsHttpUriRequest.java | 5 +++++ .../apachehttpclient/HostAndRequestAsHttpUriRequest.java | 5 +++++ .../apachehttpclient5/HostAndRequestAsHttpUriRequest.java | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/HostAndRequestAsHttpUriRequest.java b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/HostAndRequestAsHttpUriRequest.java index 7bf1f316b60..857f77881b5 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/HostAndRequestAsHttpUriRequest.java +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/HostAndRequestAsHttpUriRequest.java @@ -72,6 +72,11 @@ public Header getFirstHeader(String name) { return actualRequest.getFirstHeader(name); } + @Override + public Header[] getHeaders(String name) { + return actualRequest.getHeaders(name); + } + public HttpRequest getActualRequest() { return actualRequest; } diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/HostAndRequestAsHttpUriRequest.java b/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/HostAndRequestAsHttpUriRequest.java index 4d7a7ffc929..dab418e8214 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/HostAndRequestAsHttpUriRequest.java +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/HostAndRequestAsHttpUriRequest.java @@ -68,6 +68,11 @@ public Header getFirstHeader(String name) { return actualRequest.getFirstHeader(name); } + @Override + public Header[] getHeaders(String name) { + return actualRequest.getHeaders(name); + } + public HttpRequest getActualRequest() { return actualRequest; } diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/HostAndRequestAsHttpUriRequest.java b/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/HostAndRequestAsHttpUriRequest.java index da3045f8b45..709e6b317f7 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/HostAndRequestAsHttpUriRequest.java +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/HostAndRequestAsHttpUriRequest.java @@ -39,4 +39,9 @@ public void setHeader(String name, Object value) { public Header getFirstHeader(String name) { return actualRequest.getFirstHeader(name); } + + @Override + public Header[] getHeaders(String name) { + return actualRequest.getHeaders(name); + } } From dad52137314b019e9810e4e4c1799761bc34033b Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 11:28:45 -0600 Subject: [PATCH 6/9] Update Grizzly and Jetty91 getRequestHeader --- .../trace/instrumentation/grizzly/client/ClientDecorator.java | 2 +- .../instrumentation/jetty_client10/JettyClientDecorator.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/instrumentation/grizzly-client-1.9/src/main/java/datadog/trace/instrumentation/grizzly/client/ClientDecorator.java b/dd-java-agent/instrumentation/grizzly-client-1.9/src/main/java/datadog/trace/instrumentation/grizzly/client/ClientDecorator.java index d9ac7a19fb6..2086d7778d0 100644 --- a/dd-java-agent/instrumentation/grizzly-client-1.9/src/main/java/datadog/trace/instrumentation/grizzly/client/ClientDecorator.java +++ b/dd-java-agent/instrumentation/grizzly-client-1.9/src/main/java/datadog/trace/instrumentation/grizzly/client/ClientDecorator.java @@ -42,7 +42,7 @@ protected int status(final Response response) { @Override protected String getRequestHeader(Request request, String headerName) { - return request.getHeaders().getFirstValue(headerName); + return request.getHeaders().getJoinedValue(headerName, ","); } @Override diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java index 494ff08937b..c0cbc8623d6 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java @@ -3,6 +3,7 @@ import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator; import java.net.URI; +import java.util.List; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -38,7 +39,8 @@ protected int status(final Response httpResponse) { @Override protected String getRequestHeader(Request request, String headerName) { - return request.getHeaders().get(headerName); + List result = request.getHeaders().getValuesList(headerName); + return String.join(",", result); } @Override From ccbffdb2afc67f8ba358d79346875705d44bc20e Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 11:31:41 -0600 Subject: [PATCH 7/9] Update Apache getRequestHeader and getResponseHeader --- .../ApacheHttpAsyncClientDecorator.java | 26 ++++++++++++++----- .../ApacheHttpClientDecorator.java | 26 ++++++++++++++----- .../ApacheHttpClientDecorator.java | 26 ++++++++++++++----- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientDecorator.java b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientDecorator.java index e8faa71340d..d9fd30b6a42 100644 --- a/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientDecorator.java +++ b/dd-java-agent/instrumentation/apache-httpasyncclient-4/src/main/java/datadog/trace/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientDecorator.java @@ -60,9 +60,16 @@ protected int status(final HttpContext context) { @Override protected String getRequestHeader(HttpUriRequest request, String headerName) { - Header header = request.getFirstHeader(headerName); - if (header != null) { - return header.getValue(); + Header[] headers = request.getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } return null; } @@ -71,9 +78,16 @@ protected String getRequestHeader(HttpUriRequest request, String headerName) { protected String getResponseHeader(HttpContext context, String headerName) { final Object responseObject = context.getAttribute(HttpCoreContext.HTTP_RESPONSE); if (responseObject instanceof HttpResponse) { - Header header = ((HttpResponse) responseObject).getFirstHeader(headerName); - if (header != null) { - return header.getValue(); + Header[] headers = ((HttpResponse) responseObject).getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } } return null; diff --git a/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/ApacheHttpClientDecorator.java b/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/ApacheHttpClientDecorator.java index 91cee1f3f85..20bfcdfcddd 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/ApacheHttpClientDecorator.java +++ b/dd-java-agent/instrumentation/apache-httpclient-4/src/main/java/datadog/trace/instrumentation/apachehttpclient/ApacheHttpClientDecorator.java @@ -46,18 +46,32 @@ protected int status(final HttpResponse httpResponse) { @Override protected String getRequestHeader(HttpUriRequest request, String headerName) { - Header header = request.getFirstHeader(headerName); - if (null != header) { - return header.getValue(); + Header[] headers = request.getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } return null; } @Override protected String getResponseHeader(HttpResponse response, String headerName) { - Header header = response.getFirstHeader(headerName); - if (null != header) { - return header.getValue(); + Header[] headers = response.getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } return null; } diff --git a/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/ApacheHttpClientDecorator.java b/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/ApacheHttpClientDecorator.java index 78d7958d6f6..1fd29d79528 100644 --- a/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/ApacheHttpClientDecorator.java +++ b/dd-java-agent/instrumentation/apache-httpclient-5/src/main/java/datadog/trace/instrumentation/apachehttpclient5/ApacheHttpClientDecorator.java @@ -54,18 +54,32 @@ protected int status(final HttpResponse httpResponse) { @Override protected String getRequestHeader(HttpRequest request, String headerName) { - Header header = request.getFirstHeader(headerName); - if (null != header) { - return header.getValue(); + Header[] headers = request.getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } return null; } @Override protected String getResponseHeader(HttpResponse response, String headerName) { - Header header = response.getFirstHeader(headerName); - if (null != header) { - return header.getValue(); + Header[] headers = response.getHeaders(headerName); + if (headers.length > 0) { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < headers.length; i++) { + result.append(headers[i].getValue()); + if (i + 1 < headers.length) { + result.append(","); + } + } + return result.toString(); } return null; } From 4cdc4d42442c0a019bc37712df8267b581aafb51 Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 12:08:36 -0600 Subject: [PATCH 8/9] Remove JettyClient91 support --- .../instrumentation/jetty_client10/JettyClientDecorator.java | 4 +--- .../jetty-client-9.1/src/test/groovy/JettyClientTest.groovy | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java index c0cbc8623d6..494ff08937b 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-10.0/src/main/java11/datadog/trace/instrumentation/jetty_client10/JettyClientDecorator.java @@ -3,7 +3,6 @@ import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString; import datadog.trace.bootstrap.instrumentation.decorator.HttpClientDecorator; import java.net.URI; -import java.util.List; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; @@ -39,8 +38,7 @@ protected int status(final Response httpResponse) { @Override protected String getRequestHeader(Request request, String headerName) { - List result = request.getHeaders().getValuesList(headerName); - return String.join(",", result); + return request.getHeaders().get(headerName); } @Override diff --git a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy index aa97c8be1a4..42b826c9b15 100644 --- a/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy +++ b/dd-java-agent/instrumentation/jetty-client/jetty-client-9.1/src/test/groovy/JettyClientTest.groovy @@ -1,4 +1,4 @@ -import datadog.trace.agent.test.base.HttpClientTest2 +import datadog.trace.agent.test.base.HttpClientTest import datadog.trace.agent.test.naming.TestingGenericHttpNamingConventions import org.eclipse.jetty.client.HttpClient import org.eclipse.jetty.client.HttpProxy @@ -13,7 +13,7 @@ import spock.lang.Subject import java.util.concurrent.ExecutionException -abstract class JettyClientTest extends HttpClientTest2 { +abstract class JettyClientTest extends HttpClientTest { @Shared @Subject From ec51de9c4c5caf86db693848bb01b37500a0546e Mon Sep 17 00:00:00 2001 From: Sarah Chen Date: Wed, 18 Dec 2024 13:19:23 -0600 Subject: [PATCH 9/9] Fix missing header maps --- .../okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy | 2 +- .../okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy | 2 +- .../src/test/groovy/client/VertxHttpClientForkedTest.groovy | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy index d800ef19c14..8a48cd7adf8 100644 --- a/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy +++ b/dd-java-agent/instrumentation/okhttp-2/src/test/groovy/OkHttp2AsyncTest.groovy @@ -55,7 +55,7 @@ abstract class OkHttp2AsyncTest extends OkHttp2Test { def captured = AgentTracer.noopSpan() try { TraceUtils.runUnderTrace("parent", { - doRequest(method, url, ["Datadog-Meta-Lang": "java"], "", { captured = AgentTracer.activeSpan() }) + doRequest(method, url, [["Datadog-Meta-Lang", "java"]], "", { captured = AgentTracer.activeSpan() }) }) } catch (Exception e) { assert error == true diff --git a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy index cc7ded34d8e..a3a7e90a691 100644 --- a/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy +++ b/dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3AsyncTest.groovy @@ -66,7 +66,7 @@ abstract class OkHttp3AsyncTest extends OkHttp3Test { def captured = AgentTracer.noopSpan() try { TraceUtils.runUnderTrace("parent", { - doRequest(method, url, ["Datadog-Meta-Lang": "java"], "", { captured = AgentTracer.activeSpan() }) + doRequest(method, url, [["Datadog-Meta-Lang", "java"]], "", { captured = AgentTracer.activeSpan() }) }) } catch (Exception e) { assert error == true diff --git a/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy b/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy index 7cd7e5fe293..eb5597027b6 100644 --- a/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy +++ b/dd-java-agent/instrumentation/vertx-web-4.0/src/test/groovy/client/VertxHttpClientForkedTest.groovy @@ -91,7 +91,7 @@ class VertxHttpClientForkedTest extends HttpClientTest implements TestingNettyHt def "handle timeout"() { when: - def status = doRequest(method, url, [:], "", null, timeout) + def status = doRequest(method, url, [], "", null, timeout) then: status == 0