diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpClientRequest.java b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpClientRequest.java index 09f8eb9cfbda..fd20623cbafa 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpClientRequest.java +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpClientRequest.java @@ -48,7 +48,7 @@ static List headersToList(Header[] headers) { } List headersList = new ArrayList<>(headers.length); for (int i = 0; i < headers.length; ++i) { - headersList.set(i, headers[i].getValue()); + headersList.add(headers[i].getValue()); } return headersList; } diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/test/groovy/ApacheHttpAsyncClientTest.groovy b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/test/groovy/ApacheHttpAsyncClientTest.groovy index 2f4207b810d2..28d3cc108e93 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/test/groovy/ApacheHttpAsyncClientTest.groovy +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/test/groovy/ApacheHttpAsyncClientTest.groovy @@ -34,6 +34,11 @@ abstract class ApacheHttpAsyncClientTest extends HttpClientTest client.start() } + @Override + String userAgent() { + return "httpasyncclient" + } + @Override Integer responseCodeOnRedirectError() { return 302 @@ -42,6 +47,7 @@ abstract class ApacheHttpAsyncClientTest extends HttpClientTest @Override HttpUriRequest buildRequest(String method, URI uri, Map headers) { def request = createRequest(method, uri) + request.addHeader("user-agent", userAgent()) headers.entrySet().each { request.setHeader(new BasicHeader(it.key, it.value)) } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientRequest.java b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientRequest.java index b3bd19563fe6..3953afaf41e2 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientRequest.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientRequest.java @@ -54,7 +54,7 @@ static List headersToList(Header[] headers) { } List headersList = new ArrayList<>(headers.length); for (int i = 0; i < headers.length; ++i) { - headersList.set(i, headers[i].getValue()); + headersList.add(headers[i].getValue()); } return headersList; } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy index 74d44321e9dd..b9fc198335f3 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy @@ -49,9 +49,15 @@ abstract class ApacheHttpClientTest extends HttpClientTes client.getConnectionManager().shutdown() } + @Override + String userAgent() { + return "apachehttpclient" + } + @Override T buildRequest(String method, URI uri, Map headers) { def request = createRequest(method, uri) + request.addHeader("user-agent", userAgent()) headers.entrySet().each { request.setHeader(new BasicHeader(it.key, it.value)) } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientRequest.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientRequest.java index c6969394bebe..56384947ba1e 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientRequest.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientRequest.java @@ -53,7 +53,7 @@ static List headersToList(Header[] headers) { } List headersList = new ArrayList<>(headers.length); for (int i = 0; i < headers.length; ++i) { - headersList.set(i, headers[i].getValue()); + headersList.add(headers[i].getValue()); } return headersList; } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/testing/src/main/groovy/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTest.groovy b/instrumentation/apache-httpclient/apache-httpclient-4.3/testing/src/main/groovy/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTest.groovy index 1fd0654a41ba..462d5bdfa060 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/testing/src/main/groovy/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTest.groovy +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/testing/src/main/groovy/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTest.groovy @@ -24,6 +24,11 @@ abstract class ApacheHttpClientTest extends HttpClientTes abstract protected CloseableHttpClient createClient() + @Override + String userAgent() { + return "apachehttpclient" + } + @Override Integer responseCodeOnRedirectError() { return 302 @@ -35,6 +40,7 @@ abstract class ApacheHttpClientTest extends HttpClientTes @Override T buildRequest(String method, URI uri, Map headers) { def request = createRequest(method, uri) + request.addHeader("user-agent", userAgent()) headers.entrySet().each { request.setHeader(new BasicHeader(it.key, it.value)) } diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientHttpAttributesExtractor.java b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientHttpAttributesExtractor.java index fb0893c781bf..6de0f6552f6b 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientHttpAttributesExtractor.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientHttpAttributesExtractor.java @@ -138,7 +138,7 @@ private static List headersToList(Header[] headers) { } List headersList = new ArrayList<>(headers.length); for (int i = 0; i < headers.length; ++i) { - headersList.set(i, headers[i].getValue()); + headersList.add(headers[i].getValue()); } return headersList; } diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy index e71095e78797..0f118529a8ca 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/test/groovy/ApacheHttpClientTest.groovy @@ -40,9 +40,15 @@ abstract class ApacheHttpClientTest extends HttpClientTes client = builder.build() } + @Override + String userAgent() { + return "apachehttpclient" + } + @Override T buildRequest(String method, URI uri, Map headers) { def request = createRequest(method, uri) + request.addHeader("user-agent", userAgent()) headers.entrySet().each { request.setHeader(new BasicHeader(it.key, it.value)) } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/testSqs/groovy/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/SqsTracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/testSqs/groovy/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/SqsTracingTest.groovy index 80b19b8f0f67..bb273ef93a3d 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/testSqs/groovy/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/SqsTracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/testSqs/groovy/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/SqsTracingTest.groovy @@ -14,4 +14,9 @@ class SqsTracingTest extends AbstractSqsTracingTest implements AgentTestTrait { AmazonSQSAsyncClientBuilder configureClient(AmazonSQSAsyncClientBuilder client) { return client } + + @Override + boolean hasHttpClientSpan() { + true + } } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy index 0323e1d64519..d36465cbb80d 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/groovy/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsTracingTest.groovy @@ -50,6 +50,10 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { } } + boolean hasHttpClientSpan() { + false + } + def "simple sqs producer-consumer services"() { setup: client.createQueue("testSdkSqs") @@ -83,7 +87,7 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { } } } - trace(1, 2) { + trace(1, hasHttpClientSpan() ? 3 : 2) { span(0) { name "SQS.SendMessage" kind PRODUCER @@ -103,7 +107,16 @@ abstract class AbstractSqsTracingTest extends InstrumentationSpecification { "net.transport" IP_TCP } } - span(1) { + def offset = 0 + if (hasHttpClientSpan()) { + offset = 1 + span(1) { + name "HTTP POST" + kind CLIENT + childOf span(0) + } + } + span(1 + offset) { name "SQS.ReceiveMessage" kind CONSUMER childOf span(0)