Use connected field to determine io status of httpurlconnection
MODIFY
dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java
dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/HttpUrlConnectionInstrumentation.java
@@ -6,6 +6,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isPublic;
import static net.bytebuddy.matcher.ElementMatchers.isSubTypeOf;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
import com.google.auto.service.AutoService;
import datadog.trace.agent.tooling.Instrumenter;
@@ -18,6 +19,7 @@ import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
+import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
@@ -41,7 +43,9 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
@Override
public ElementMatcher typeMatcher() {
- return isSubTypeOf(HttpURLConnection.class);
+ return isSubTypeOf(HttpURLConnection.class)
+ // This class is a simple delegator. Skip because it does not update its `connected` field.
+ .and(not(named("sun.net.www.protocol.https.HttpsURLConnectionImpl")));
}
@Override
@@ -59,6 +63,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
.and(isPublic())
.and(
named("getResponseCode")
+ .or(named("connect"))
.or(named("getOutputStream"))
.or(named("getInputStream"))
.or(nameStartsWith("getHeaderField"))),
@@ -70,13 +75,20 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
@Advice.OnMethodEnter(suppress = Throwable.class)
public static Scope startSpan(
- @Advice.This final HttpURLConnection connection,
- @Advice.FieldValue("connected") final boolean connected,
- @Advice.Origin("#m") final String methodName) {
+ @Advice.This final HttpURLConnection thiz,
+ @Advice.FieldValue("connected") final boolean connected) {
+ // This works with keep-alive because the "connected" flag is not initialized until the socket cache is checked.
+ // This allows us to use the connected flag to know if this instance has done any io.
+ if (connected) {
+ return null;
+ }
+
+ // AgentWriter uses HttpURLConnection to report to the trace-agent. We don't want to trace those requests.
+ // Check after the connected test above because getRequestProperty will throw an exception if already connected.
final boolean isTraceRequest =
Thread.currentThread().getName().equals("dd-agent-writer")
- || connection.getRequestProperty("Datadog-Meta-Lang") != null;
+ || thiz.getRequestProperty("Datadog-Meta-Lang") != null;
if (isTraceRequest) {
return null;
}
@@ -86,56 +98,38 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
return null;
}
- String protocol = "url";
- if (connection != null) {
- final URL url = connection.getURL();
- protocol = url.getProtocol();
- }
-
- String command = ".request.response_code";
- if (methodName.equals("getOutputStream")) {
- command = ".request.output_stream";
- } else if (methodName.equals("getInputStream")) {
- command = ".request.input_stream";
- }
+ final String protocol = thiz.getURL().getProtocol();
final Tracer tracer = GlobalTracer.get();
final Scope scope =
tracer
- .buildSpan(protocol + command)
+ .buildSpan("http.request")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.startActive(true);
- if (connection != null) {
- final URL url = connection.getURL();
+ final URL url = thiz.getURL();
final Span span = scope.span();
- Tags.COMPONENT.set(scope.span(), connection.getClass().getSimpleName());
+ Tags.COMPONENT.set(scope.span(), thiz.getClass().getSimpleName());
Tags.HTTP_URL.set(span, url.toString());
Tags.PEER_HOSTNAME.set(span, url.getHost());
if (url.getPort() > 0) {
Tags.PEER_PORT.set(span, url.getPort());
- } else if (connection instanceof HttpsURLConnection) {
+ } else if (thiz instanceof HttpsURLConnection) {
Tags.PEER_PORT.set(span, 443);
} else {
Tags.PEER_PORT.set(span, 80);
}
+ Tags.HTTP_METHOD.set(span, thiz.getRequestMethod());
- Tags.HTTP_METHOD.set(span, connection.getRequestMethod());
-
- if (!connected) {
tracer.inject(
- span.context(),
- Format.Builtin.HTTP_HEADERS,
- new MessageHeadersInjectAdapter(connection));
- }
- }
+ span.context(), Format.Builtin.HTTP_HEADERS, new MessageHeadersInjectAdapter(thiz));
return scope;
}
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
- @Advice.FieldValue("responseCode") final int responseCode,
+ @Advice.This final HttpURLConnection thiz,
@Advice.Enter final Scope scope,
@Advice.Thrown final Throwable throwable) {
@@ -144,12 +138,17 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
}
final Span span = scope.span();
-
if (throwable != null) {
Tags.ERROR.set(span, true);
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
- } else if (responseCode > 0) {
- Tags.HTTP_STATUS.set(span, responseCode);
+ } else {
+ try {
+ // response code field is sometimes not populated until the getResponseCode method is explicitly called.
+ // Calling getResponseCode() here will not trigger additional instrumentation because we have not reset the depth map.
+ Tags.HTTP_STATUS.set(span, thiz.getResponseCode());
+ } catch (IOException ioe) {
+ // ignore
+ }
}
scope.close();
CallDepthThreadLocalMap.reset(HttpURLConnection.class);

DELETE
dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/SunHttpUrlConnectionInstrumentation.java
-package datadog.trace.instrumentation.http_url_connection;
-
-import static io.opentracing.log.Fields.ERROR_OBJECT;
-import static net.bytebuddy.matcher.ElementMatchers.*;
-
-import com.google.auto.service.AutoService;
-import datadog.trace.agent.tooling.Instrumenter;
-import datadog.trace.api.DDSpanTypes;
-import datadog.trace.api.DDTags;
-import datadog.trace.bootstrap.CallDepthThreadLocalMap;
-import io.opentracing.Scope;
-import io.opentracing.Span;
-import io.opentracing.Tracer;
-import io.opentracing.propagation.Format;
-import io.opentracing.tag.Tags;
-import io.opentracing.util.GlobalTracer;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import net.bytebuddy.asm.Advice;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.slf4j.LoggerFactory;
-
-@AutoService(Instrumenter.class)
-public class SunHttpUrlConnectionInstrumentation extends Instrumenter.Default {
-
- public SunHttpUrlConnectionInstrumentation() {
- super("httpurlconnection", "sun-httpurlconnection");
- }
-
- @Override
- protected boolean defaultEnabled() {
- return false;
- }
-
- @Override
- public ElementMatcher typeMatcher() {
- return isSubTypeOf(java.net.HttpURLConnection.class)
- .and(is(sun.net.www.protocol.http.HttpURLConnection.class));
- }
-
- @Override
- public String[] helperClassNames() {
- return new String[] {
- "datadog.trace.instrumentation.http_url_connection.MessageHeadersInjectAdapter"
- };
- }
-
- @Override
- public Map<ElementMatcher, String> transformers() {
- Map<ElementMatcher, String> transformers = new HashMap<>();
- transformers.put(
- isMethod()
- .and(isPublic())
- .and(
- named("getResponseCode")
- .or(named("getOutputStream"))
- .or(named("getInputStream"))
- .or(nameStartsWith("getHeaderField"))),
- HttpUrlConnectionAdvice.class.getName());
- return transformers;
- }
-
- public static class HttpUrlConnectionAdvice {
-
- @Advice.OnMethodEnter(suppress = Throwable.class)
- public static Scope startSpan(
- @Advice.This final sun.net.www.protocol.http.HttpURLConnection connection,
- @Advice.FieldValue("connected") final boolean connected,
- @Advice.FieldValue("responseCode") final int responseCode,
- @Advice.FieldValue("responseMessage") final String responseMessage,
- @Advice.FieldValue("inputStream") final InputStream inputStream,
- @Advice.FieldValue("cachedInputStream") final InputStream cachedInputStream,
- @Advice.Origin("#m") final String methodName) {
-
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("ENTERING-----------------");
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("connected? " + connected);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class).warn("responseCode: " + responseCode);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class).warn("responseMessage: " + responseMessage);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class).warn("cachedInputStream: " + cachedInputStream);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class).warn("cachedInputStream: " + cachedInputStream);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("connection: " + connection.toString() + ", HASH: " + connection.hashCode());
-
- final boolean isTraceRequest =
- Thread.currentThread().getName().equals("dd-agent-writer")
- || connection.getRequestProperty("Datadog-Meta-Lang") != null;
- if (isTraceRequest) {
- return null;
- }
-
- // inputstream not null, so don't start span
- if (cachedInputStream != null || inputStream != null) {
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("span not started because INPUTSTREAM NOT NULL ");
- return null;
- }
-
- if (responseCode <= 0 && responseMessage == null) {
- final int callDepth =
- CallDepthThreadLocalMap.incrementCallDepth(
- sun.net.www.protocol.http.HttpURLConnection.class);
- if (callDepth > 0) {
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("span not started because callDepth " + callDepth);
- return null;
- }
-
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("CREATING-----------------");
- String protocol = "url";
- if (connection != null) {
- final URL url = connection.getURL();
- protocol = url.getProtocol();
- }
-
- try {
- throw new Exception("A");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- String command = ".request.response_code";
- if (methodName.equals("getOutputStream")) {
- command = ".request.output_stream";
- } else if (methodName.equals("getInputStream")) {
- command = ".request.input_stream";
- }
-
- final Tracer tracer = GlobalTracer.get();
- final Scope scope =
- tracer
- .buildSpan(protocol + command)
- .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
- .withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
- .startActive(true);
-
- return scope;
- } else {
- return null;
- }
- }
-
- @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
- public static void stopSpan(
- @Advice.This final sun.net.www.protocol.http.HttpURLConnection httpURLConnection,
- @Advice.FieldValue("responseCode") final int responseCode,
- @Advice.Enter final Scope scope,
- @Advice.Thrown final Throwable throwable) {
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("EXITING-----------------");
- if (scope == null) {
- return;
- }
-
- if (httpURLConnection != null) {
- final URL url = httpURLConnection.getURL();
- final Span span = scope.span();
- Tags.COMPONENT.set(scope.span(), httpURLConnection.getClass().getSimpleName());
- Tags.HTTP_URL.set(span, url.toString());
- Tags.PEER_HOSTNAME.set(span, url.getHost());
- if (url.getPort() > 0) {
- Tags.PEER_PORT.set(span, url.getPort());
- }
-
- Tags.HTTP_METHOD.set(span, httpURLConnection.getRequestMethod());
- final Tracer tracer = GlobalTracer.get();
- if (httpURLConnection == null) {
- tracer.inject(
- span.context(),
- Format.Builtin.HTTP_HEADERS,
- new MessageHeadersInjectAdapter(httpURLConnection));
- }
- }
-
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("CLOSING-----------------");
-
- // should consider using getResponseCode to get a better response code.
- int rescode = -2;
- // try {
- // rescode = httpURLConnection.getResponseCode();
- // } catch (Exception e) {
- // //we
- // }
-
- final Span span = scope.span();
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("responseCode: " + responseCode);
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("rescode: " + rescode);
- if (throwable != null) {
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("DERROR " + throwable.getMessage());
- Tags.ERROR.set(span, true);
- span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
- } else if (responseCode > 0) {
- LoggerFactory.getLogger(sun.net.www.protocol.http.HttpURLConnection.class)
- .warn("setting tag res code: " + responseCode);
- Tags.HTTP_STATUS.set(span, responseCode);
- }
- scope.close();
- CallDepthThreadLocalMap.reset(sun.net.www.protocol.http.HttpURLConnection.class);
- }
- }
-}

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/HttpUrlConnectionTest.groovy
@@ -17,8 +17,7 @@ import static ratpack.http.HttpMethod.POST
class HttpUrlConnectionTest extends AgentTestRunner {
static {
- System.setProperty("dd.integration.httpurlconnection.enabled", "false")
- System.setProperty("dd.integration.sun-httpurlconnection.enabled", "true")
+ System.setProperty("dd.integration.httpurlconnection.enabled", "true")
}
static final RESPONSE = "<html><body><h1>Hello test.</h1>"
@@ -69,7 +68,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
trace(0, 1) {
span(0) {
operationName "test-http-server"
- childOf(TEST_WRITER[2][4])
+ childOf(TEST_WRITER[2][2])
errored false
tags {
defaultTags()
@@ -79,14 +78,14 @@ class HttpUrlConnectionTest extends AgentTestRunner {
trace(1, 1) {
span(0) {
operationName "test-http-server"
- childOf(TEST_WRITER[2][2])
+ childOf(TEST_WRITER[2][1])
errored false
tags {
defaultTags()
}
}
}
- trace(2, 5) {
+ trace(2, 3) {
span(0) {
operationName "someTrace"
parent()
@@ -96,7 +95,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(1) {
- operationName "http.request.input_stream"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -112,39 +111,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(2) {
- operationName "http.request.response_code"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "GET"
- "$Tags.HTTP_STATUS.key" STATUS
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
- span(3) {
- operationName "http.request.response_code"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "GET"
- "$Tags.HTTP_STATUS.key" STATUS
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
- span(4) {
- operationName "http.request.input_stream"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -188,7 +155,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
expect:
assertTraces(TEST_WRITER, 1) {
- trace(0, 5) {
+ trace(0, 3) {
span(0) {
operationName "someTrace"
parent()
@@ -198,7 +165,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(1) {
- operationName "http.request.input_stream"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -214,39 +181,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(2) {
- operationName "http.request.response_code"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "GET"
- "$Tags.HTTP_STATUS.key" STATUS
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
- span(3) {
- operationName "http.request.response_code"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "GET"
- "$Tags.HTTP_STATUS.key" STATUS
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
- span(4) {
- operationName "http.request.input_stream"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -287,7 +222,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(1) {
- operationName "http.request.response_code"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -334,14 +269,14 @@ class HttpUrlConnectionTest extends AgentTestRunner {
trace(0, 1) {
span(0) {
operationName "test-http-server"
- childOf(TEST_WRITER[1][3])
+ childOf(TEST_WRITER[1][1])
errored false
tags {
defaultTags()
}
}
}
- trace(1, 4) {
+ trace(1, 2) {
span(0) {
operationName "someTrace"
parent()
@@ -351,23 +286,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
}
span(1) {
- operationName "http.request.input_stream"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "POST"
- "$Tags.HTTP_STATUS.key" STATUS
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
- span(2) {
- operationName "http.request.response_code"
+ operationName "http.request"
childOf span(0)
errored false
tags {
@@ -382,21 +301,6 @@ class HttpUrlConnectionTest extends AgentTestRunner {
defaultTags()
}
}
- span(3) {
- operationName "http.request.output_stream"
- childOf span(0)
- errored false
- tags {
- "$Tags.COMPONENT.key" "HttpURLConnection"
- "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
- "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
- "$Tags.HTTP_URL.key" "$server.address"
- "$Tags.HTTP_METHOD.key" "POST"
- "$Tags.PEER_HOSTNAME.key" "localhost"
- "$Tags.PEER_PORT.key" server.address.port
- defaultTags()
- }
- }
}
}
}
@@ -430,14 +334,80 @@ class HttpUrlConnectionTest extends AgentTestRunner {
}
def "rest template"() {
- when:
+ setup:
+ runUnderTrace("someTrace") {
RestTemplate restTemplate = new RestTemplate()
- String res = restTemplate.getForObject("https://gturnquist-quoters.cfapps.io/api/random", String.class)
+ String res = restTemplate.getForObject(server.address.toString(), String)
+ assert res == RESPONSE
+ String res2 = restTemplate.getForObject(server.address.toString(), String)
+ assert res2 == RESPONSE
+ }
- then:
- println(res)
- println(TEST_WRITER.size())
- println(TEST_WRITER[0].size())
+ expect:
+ assertTraces(TEST_WRITER, 3) {
+ trace(0, 1) {
+ span(0) {
+ operationName "test-http-server"
+ childOf(TEST_WRITER[2][2])
+ errored false
+ tags {
+ defaultTags()
+ }
+ }
+ }
+ trace(1, 1) {
+ span(0) {
+ operationName "test-http-server"
+ childOf(TEST_WRITER[2][1])
+ errored false
+ tags {
+ defaultTags()
+ }
+ }
+ }
+ trace(2, 3) {
+ span(0) {
+ operationName "someTrace"
+ parent()
+ errored false
+ tags {
+ defaultTags()
+ }
+ }
+ span(1) {
+ operationName "http.request"
+ childOf span(0)
+ errored false
+ tags {
+ "$Tags.COMPONENT.key" "HttpURLConnection"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
+ "$Tags.HTTP_URL.key" "$server.address"
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_STATUS.key" STATUS
+ "$Tags.PEER_HOSTNAME.key" "localhost"
+ "$Tags.PEER_PORT.key" server.address.port
+ defaultTags()
+ }
+ }
+ span(2) {
+ operationName "http.request"
+ childOf span(0)
+ errored false
+ tags {
+ "$Tags.COMPONENT.key" "HttpURLConnection"
+ "$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
+ "$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
+ "$Tags.HTTP_URL.key" "$server.address"
+ "$Tags.HTTP_METHOD.key" "GET"
+ "$Tags.HTTP_STATUS.key" STATUS
+ "$Tags.PEER_HOSTNAME.key" "localhost"
+ "$Tags.PEER_PORT.key" server.address.port
+ defaultTags()
+ }
+ }
+ }
+ }
}
private static class RatpackResponseAdapter implements TextMap {

MODIFY
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy
dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy
@@ -41,7 +41,7 @@ class UrlConnectionTest extends AgentTestRunner {
}
}
span(1) {
- operationName "${scheme}.request.input_stream"
+ operationName "http.request"
childOf span(0)
errored true
tags {
@@ -62,7 +62,7 @@ class UrlConnectionTest extends AgentTestRunner {
where:
scheme | component
"http" | "HttpURLConnection"
- "https" | "HttpsURLConnectionImpl"
+ "https" | "DelegateHttpsURLConnection"
url = new URI("$scheme://localhost:$INVALID_PORT").toURL()
}

Use connected field to determine io status of httpurlconnection