Add HttpAsyncClient to Elasticsearch for verification.
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/HttpClientDecorator.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/HttpClientDecorator.java
@@ -34,7 +34,8 @@ public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends ClientDecor
Tags.HTTP_METHOD.set(span, method(request));
Tags.HTTP_URL.set(span, url(request));
Tags.PEER_HOSTNAME.set(span, hostname(request));
- Tags.PEER_PORT.set(span, port(request));
+ final Integer port = port(request);
+ Tags.PEER_PORT.set(span, port != null && port > 0 ? port : null);
if (Config.get().isHttpClientSplitByDomain()) {
span.setTag(DDTags.SERVICE_NAME, hostname(request));

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-5/rest-5.gradle
dd-java-agent/instrumentation/elasticsearch/rest-5/rest-5.gradle
@@ -38,10 +38,8 @@ dependencies {
implementation deps.autoservice
testCompile project(':dd-java-agent:testing')
- // Include httpclient instrumentation for testing because it is a dependency for elasticsearch-rest-client.
- // It doesn't actually work though. They use HttpAsyncClient, which isn't currently instrumented.
- // TODO: add Apache's HttpAsyncClient instrumentation when that is complete.
testCompile project(':dd-java-agent:instrumentation:apache-httpclient-4')
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy
dd-java-agent/instrumentation/elasticsearch/rest-5/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy
@@ -78,7 +78,7 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
result.status == "green"
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
serviceName "elasticsearch"
resourceName "GET _cluster/health"
@@ -96,6 +96,21 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
defaultTags()
}
}
+ span(1) {
+ serviceName "elasticsearch"
+ resourceName "GET _cluster/health"
+ operationName "http.request"
+ spanType DDSpanTypes.HTTP_CLIENT
+ childOf span(0)
+ tags {
+ "$Tags.COMPONENT.key" "apache-httpasyncclient"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_URL.key" "_cluster/health"
+ "$Tags.HTTP_STATUS.key" 200
+ defaultTags()
+ }
+ }
}
}
}

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy
dd-java-agent/instrumentation/elasticsearch/rest-5/src/test/groovy/Elasticsearch5RestClientTest.groovy
@@ -83,7 +83,7 @@ class Elasticsearch5RestClientTest extends AgentTestRunner {
result.status == "green"
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
serviceName "elasticsearch"
resourceName "GET _cluster/health"
@@ -101,6 +101,21 @@ class Elasticsearch5RestClientTest extends AgentTestRunner {
defaultTags()
}
}
+ span(1) {
+ serviceName "elasticsearch"
+ resourceName "GET _cluster/health"
+ operationName "http.request"
+ spanType DDSpanTypes.HTTP_CLIENT
+ childOf span(0)
+ tags {
+ "$Tags.COMPONENT.key" "apache-httpasyncclient"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_URL.key" "_cluster/health"
+ "$Tags.HTTP_STATUS.key" 200
+ defaultTags()
+ }
+ }
}
}
}

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-6.4/rest-6.4.gradle
dd-java-agent/instrumentation/elasticsearch/rest-6.4/rest-6.4.gradle
@@ -39,10 +39,10 @@ dependencies {
implementation deps.autoservice
testCompile project(':dd-java-agent:testing')
- // Include httpclient instrumentation for testing because it is a dependency for elasticsearch-rest-client.
- // It doesn't actually work though. They use HttpAsyncClient, which isn't currently instrumented.
- // TODO: add Apache's HttpAsyncClient instrumentation when that is complete.
testCompile project(':dd-java-agent:instrumentation:apache-httpclient-4')
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
+ // Netty is used, but it adds complexity to the tests since we're using embedded ES.
+ //testCompile project(':dd-java-agent:instrumentation:netty-4.1')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy
dd-java-agent/instrumentation/elasticsearch/rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy
@@ -82,7 +82,7 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
result.status == "green"
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
serviceName "elasticsearch"
resourceName "GET _cluster/health"
@@ -100,6 +100,21 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
defaultTags()
}
}
+ span(1) {
+ serviceName "elasticsearch"
+ resourceName "GET _cluster/health"
+ operationName "http.request"
+ spanType DDSpanTypes.HTTP_CLIENT
+ childOf span(0)
+ tags {
+ "$Tags.COMPONENT.key" "apache-httpasyncclient"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_URL.key" "_cluster/health"
+ "$Tags.HTTP_STATUS.key" 200
+ defaultTags()
+ }
+ }
}
}
}

MODIFY
dd-java-agent/instrumentation/elasticsearch/rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy
dd-java-agent/instrumentation/elasticsearch/rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy
@@ -78,7 +78,7 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
result.status == "green"
assertTraces(1) {
- trace(0, 1) {
+ trace(0, 2) {
span(0) {
serviceName "elasticsearch"
resourceName "GET _cluster/health"
@@ -96,6 +96,21 @@ class Elasticsearch6RestClientTest extends AgentTestRunner {
defaultTags()
}
}
+ span(1) {
+ serviceName "elasticsearch"
+ resourceName "GET _cluster/health"
+ operationName "http.request"
+ spanType DDSpanTypes.HTTP_CLIENT
+ childOf span(0)
+ tags {
+ "$Tags.COMPONENT.key" "apache-httpasyncclient"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_URL.key" "_cluster/health"
+ "$Tags.HTTP_STATUS.key" 200
+ defaultTags()
+ }
+ }
}
}
}

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-2/transport-2.gradle
dd-java-agent/instrumentation/elasticsearch/transport-2/transport-2.gradle
@@ -36,6 +36,7 @@ dependencies {
// Ensure no cross interference
testCompile project(':dd-java-agent:instrumentation:elasticsearch:rest-5')
testCompile project(':dd-java-agent:instrumentation:elasticsearch:transport-5')
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
testCompile group: 'org.elasticsearch', name: 'elasticsearch', version: '2.0.0'

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
@@ -40,6 +40,8 @@ dependencies {
implementation deps.autoservice
testCompile project(':dd-java-agent:testing')
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
+ testCompile project(':dd-java-agent:instrumentation:netty-4.1')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5/transport-5.gradle
dd-java-agent/instrumentation/elasticsearch/transport-5/transport-5.gradle
@@ -42,11 +42,8 @@ dependencies {
testCompile project(':dd-java-agent:testing')
// Ensure no cross interference
testCompile project(':dd-java-agent:instrumentation:elasticsearch:rest-5')
- // Include httpclient instrumentation for testing because it is a dependency for elasticsearch-rest-client.
- // It doesn't actually work though. They use HttpAsyncClient, which isn't currently instrumented.
- // TODO: add HttpAsyncClient instrumentation when that is complete.
- testCompile project(':dd-java-agent:instrumentation:apache-httpclient-4')
- // TODO: add netty instrumentation when that is complete.
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
+ testCompile project(':dd-java-agent:instrumentation:netty-4.1')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-6/transport-6.gradle
dd-java-agent/instrumentation/elasticsearch/transport-6/transport-6.gradle
@@ -42,10 +42,8 @@ dependencies {
testCompile project(':dd-java-agent:testing')
// Ensure no cross interference
testCompile project(':dd-java-agent:instrumentation:elasticsearch:rest-5')
- // Include httpclient instrumentation for testing because it is a dependency for elasticsearch-rest-client.
- // It doesn't actually work though. They use HttpAsyncClient, which isn't currently instrumented.
- // TODO: add HttpAsyncClient instrumentation when that is complete.
- testCompile project(':dd-java-agent:instrumentation:apache-httpclient-4')
+ testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
+ testCompile project(':dd-java-agent:instrumentation:netty-4.1')
testCompile group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '6.0.0'
testCompile group: 'org.elasticsearch.client', name: 'transport', version: '6.0.0'

Add HttpAsyncClient to Elasticsearch for verification.