http clients
MODIFY
dd-java-agent/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy
dd-java-agent/instrumentation/akka-http-10.0/src/test/groovy/AkkaHttpClientInstrumentationTest.groovy
@@ -93,6 +93,7 @@ class AkkaHttpClientInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "akka-http.request"
resourceName "GET /$route"
+ spanType DDSpanTypes.HTTP_CLIENT
errored expectedError
tags {
defaultTags()
@@ -137,6 +138,7 @@ class AkkaHttpClientInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "akka-http.request"
resourceName "GET /test"
+ spanType DDSpanTypes.HTTP_CLIENT
errored true
tags {
defaultTags()
@@ -167,6 +169,7 @@ class AkkaHttpClientInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "akka-http.request"
resourceName "akka-http.request"
+ spanType DDSpanTypes.HTTP_CLIENT
errored true
tags {
defaultTags()
@@ -219,6 +222,7 @@ class AkkaHttpClientInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "akka-http.request"
resourceName "GET /$route"
+ spanType DDSpanTypes.HTTP_CLIENT
errored expectedError
tags {
defaultTags()
@@ -264,6 +268,7 @@ class AkkaHttpClientInstrumentationTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "akka-http.request"
resourceName "GET /test"
+ spanType DDSpanTypes.HTTP_CLIENT
errored true
tags {
defaultTags()

MODIFY
dd-java-agent/instrumentation/apache-httpclient-4.3/src/test/groovy/ApacheHttpClientTest.groovy
dd-java-agent/instrumentation/apache-httpclient-4.3/src/test/groovy/ApacheHttpClientTest.groovy
@@ -87,6 +87,7 @@ class ApacheHttpClientTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "http.request"
resourceName "GET /"
+ spanType DDSpanTypes.HTTP_CLIENT
errored false
tags {
defaultTags()
@@ -149,6 +150,7 @@ class ApacheHttpClientTest extends AgentTestRunner {
serviceName "unnamed-java-app"
operationName "http.request"
resourceName "GET /"
+ spanType DDSpanTypes.HTTP_CLIENT
errored false
tags {
defaultTags()

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/TracingCallFactory.java
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/TracingCallFactory.java
package datadog.trace.instrumentation.okhttp3;
+import datadog.trace.api.DDSpanTypes;
+import datadog.trace.api.DDTags;
import io.opentracing.Scope;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
@@ -49,6 +51,8 @@ public class TracingCallFactory implements Call.Factory {
tracer
.buildSpan("http.request")
.withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME)
+ .withTag(DDTags.SERVICE_NAME, COMPONENT_NAME)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.startActive(false);
/** In case of exception network interceptor is not called */
@@ -106,10 +110,11 @@ public class TracingCallFactory implements Call.Factory {
@Override
public Response intercept(final Chain chain) throws IOException {
- try (Scope networkScope =
+ try (final Scope networkScope =
tracer
.buildSpan("http.request")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.asChildOf(parentContext)
.startActive(true)) {

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/TracingInterceptor.java
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/TracingInterceptor.java
package datadog.trace.instrumentation.okhttp3;
+import static datadog.trace.instrumentation.okhttp3.TracingCallFactory.COMPONENT_NAME;
+
+import datadog.trace.api.DDSpanTypes;
+import datadog.trace.api.DDTags;
import io.opentracing.Scope;
import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
@@ -21,20 +25,8 @@ import okhttp3.Response;
* use. This instrumentation fails to properly infer parent span when doing simultaneously
* asynchronous calls.
*
- * <p>
- *
- * <p>
- *
- * <p>
- *
* <p>Initialization via {@link TracingInterceptor#addTracing(OkHttpClient.Builder, Tracer, List)}
*
- * <p>
- *
- * <p>
- *
- * <p>
- *
* <p>or instantiate the interceptor and add it to {@link
* OkHttpClient.Builder#addInterceptor(Interceptor)} and {@link
* OkHttpClient.Builder#addNetworkInterceptor(Interceptor)}.
@@ -97,7 +89,9 @@ public class TracingInterceptor implements Interceptor {
final Scope scope =
tracer
.buildSpan("http.request")
- .withTag(Tags.COMPONENT.getKey(), TracingCallFactory.COMPONENT_NAME)
+ .withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME)
+ .withTag(DDTags.SERVICE_NAME, COMPONENT_NAME)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.startActive(true);
final Request.Builder requestBuilder = chain.request().newBuilder();

MODIFY
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
dd-java-agent/instrumentation/okhttp-3/src/test/groovy/OkHttp3Test.groovy
@@ -43,14 +43,14 @@ class OkHttp3Test extends AgentTestRunner {
span1.context().operationName == "okhttp.http"
span1.serviceName == "okhttp"
span1.resourceName == "okhttp.http"
- span1.type == DDSpanTypes.WEB_SERVLET
+ span1.type == DDSpanTypes.HTTP_CLIENT
!span1.context().getErrorFlag()
span1.context().parentId == "0"
def tags1 = span1.context().tags
tags1["component"] == "okhttp"
- tags1["span.type"] == DDSpanTypes.WEB_SERVLET
+ tags1["span.type"] == DDSpanTypes.HTTP_CLIENT
tags1["thread.name"] != null
tags1["thread.id"] != null
tags1.size() == 4
@@ -61,7 +61,7 @@ class OkHttp3Test extends AgentTestRunner {
span2.context().operationName == "okhttp.http"
span2.serviceName == "okhttp"
span2.resourceName == "GET /ping"
- span2.type == "web"
+ span2.type == DDSpanTypes.HTTP_CLIENT
!span2.context().getErrorFlag()
span2.context().parentId == span1.spanId
@@ -69,6 +69,7 @@ class OkHttp3Test extends AgentTestRunner {
def tags2 = span2.context().tags
tags2[Tags.COMPONENT.key] == "okhttp"
tags2[Tags.SPAN_KIND.key] == Tags.SPAN_KIND_CLIENT
+ tags2[DDTags.SPAN_TYPE] == DDSpanTypes.HTTP_CLIENT
tags2[Tags.HTTP_METHOD.key] == "GET"
tags2[Tags.HTTP_URL.key] == "http://localhost:$server.address.port/ping"
tags2[Tags.PEER_HOSTNAME.key] == "localhost"

MODIFY
dd-java-agent/instrumentation/ratpack-1.4/src/main/java8/datadog/trace/instrumentation/ratpack/impl/WrappedRequestSpec.java
dd-java-agent/instrumentation/ratpack-1.4/src/main/java8/datadog/trace/instrumentation/ratpack/impl/WrappedRequestSpec.java
package datadog.trace.instrumentation.ratpack.impl;
+import datadog.trace.api.DDSpanTypes;
+import datadog.trace.api.DDTags;
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;
@@ -27,7 +29,11 @@ public final class WrappedRequestSpec implements RequestSpec {
private final Scope scope;
private final AtomicReference<Span> spanRef;
- WrappedRequestSpec(RequestSpec spec, Tracer tracer, Scope scope, AtomicReference<Span> spanRef) {
+ WrappedRequestSpec(
+ final RequestSpec spec,
+ final Tracer tracer,
+ final Scope scope,
+ final AtomicReference<Span> spanRef) {
this.delegate = spec;
this.tracer = tracer;
this.scope = scope;
@@ -40,22 +46,22 @@ public final class WrappedRequestSpec implements RequestSpec {
* a new span is created.
*
*/
- private Action<? super RequestSpec> redirectHandler(ReceivedResponse response) {
+ private Action<? super RequestSpec> redirectHandler(final ReceivedResponse response) {
// handler.handleReceive(response.getStatusCode(), null, span.get());
return (s) -> new WrappedRequestSpec(s, tracer, scope, spanRef);
}
@Override
- public RequestSpec redirects(int maxRedirects) {
+ public RequestSpec redirects(final int maxRedirects) {
this.delegate.redirects(maxRedirects);
return this;
}
@Override
public RequestSpec onRedirect(
- Function<? super ReceivedResponse, Action<? super RequestSpec>> function) {
+ final Function<? super ReceivedResponse, Action<? super RequestSpec>> function) {
- Function<? super ReceivedResponse, Action<? super RequestSpec>> wrapped =
+ final Function<? super ReceivedResponse, Action<? super RequestSpec>> wrapped =
(ReceivedResponse response) -> redirectHandler(response).append(function.apply(response));
this.delegate.onRedirect(wrapped);
@@ -63,7 +69,7 @@ public final class WrappedRequestSpec implements RequestSpec {
}
@Override
- public RequestSpec sslContext(SSLContext sslContext) {
+ public RequestSpec sslContext(final SSLContext sslContext) {
this.delegate.sslContext(sslContext);
return this;
}
@@ -74,25 +80,26 @@ public final class WrappedRequestSpec implements RequestSpec {
}
@Override
- public RequestSpec maxContentLength(int numBytes) {
+ public RequestSpec maxContentLength(final int numBytes) {
this.delegate.maxContentLength(numBytes);
return this;
}
@Override
- public RequestSpec headers(Action<? super MutableHeaders> action) throws Exception {
+ public RequestSpec headers(final Action<? super MutableHeaders> action) throws Exception {
this.delegate.headers(action);
return this;
}
@Override
- public RequestSpec method(HttpMethod method) {
- Span span =
+ public RequestSpec method(final HttpMethod method) {
+ final Span span =
tracer
.buildSpan("ratpack.client-request")
.asChildOf(scope != null ? scope.span() : null)
.withTag(Tags.COMPONENT.getKey(), "httpclient")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
+ .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.withTag(Tags.HTTP_URL.getKey(), getUri().toString())
.withTag(Tags.HTTP_METHOD.getKey(), method.getName())
.start();
@@ -103,7 +110,7 @@ public final class WrappedRequestSpec implements RequestSpec {
}
@Override
- public RequestSpec decompressResponse(boolean shouldDecompress) {
+ public RequestSpec decompressResponse(final boolean shouldDecompress) {
this.delegate.decompressResponse(shouldDecompress);
return this;
}
@@ -114,13 +121,13 @@ public final class WrappedRequestSpec implements RequestSpec {
}
@Override
- public RequestSpec connectTimeout(Duration duration) {
+ public RequestSpec connectTimeout(final Duration duration) {
this.delegate.connectTimeout(duration);
return this;
}
@Override
- public RequestSpec readTimeout(Duration duration) {
+ public RequestSpec readTimeout(final Duration duration) {
this.delegate.readTimeout(duration);
return this;
}
@@ -131,7 +138,7 @@ public final class WrappedRequestSpec implements RequestSpec {
}
@Override
- public RequestSpec body(Action<? super Body> action) throws Exception {
+ public RequestSpec body(final Action<? super Body> action) throws Exception {
this.delegate.body(action);
return this;
}

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
@@ -8,20 +8,15 @@ import java.util.Map;
public class DDDecoratorsFactory {
public static List<AbstractDecorator> createBuiltinDecorators(
final Map<String, String> mappings) {
- final HTTPComponent httpDecorator1 = new HTTPComponent();
- httpDecorator1.setMatchingTag("component");
- httpDecorator1.setMatchingValue("okhttp");
-
- final HTTPComponent httpDecorator2 = new HTTPComponent();
- httpDecorator2.setMatchingTag("component");
- httpDecorator2.setMatchingValue("java-aws-sdk");
+ final HTTPComponent httpDecorator = new HTTPComponent();
+ httpDecorator.setMatchingTag("component");
+ httpDecorator.setMatchingValue("java-aws-sdk");
return Arrays.asList(
new DBStatementAsResourceName(),
new DBTypeDecorator(),
new ErrorFlag(),
- httpDecorator1,
- httpDecorator2,
+ httpDecorator,
new OperationDecorator(),
new PeerServiceDecorator(),
new ResourceNameDecorator(),

http clients