Add HttpAsyncClient to Elasticsearch for verification.

This commit is contained in:
Tyler Benson 2019-04-25 16:14:51 -07:00
parent 9ad06a6791
commit 20df3aa18e
11 changed files with 77 additions and 20 deletions

View File

@ -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));

View File

@ -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'

View File

@ -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()
}
}
}
}
}

View File

@ -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()
}
}
}
}
}

View File

@ -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'

View File

@ -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()
}
}
}
}
}

View File

@ -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()
}
}
}
}
}

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'