Skip to content

Commit f89dfd6

Browse files
authored
Disable URL instrumentation by default (#7073)
Avoids creating unnecessary spans when exceptions occur during custom non-HTTP connections, like the custom Jar connection recently added in #7049. Note the respective instrumentation in OpenTelemetry was also removed for the same reason. Exceptions during HTTP connections are already captured by HttpUrlConnectionInstrumentation. The URL instrumentation can be re-enabled with `DD_INTEGRATION_URLCONNECTION_ENABLED=true`
1 parent 779360e commit f89dfd6

File tree

2 files changed

+5
-48
lines changed

2 files changed

+5
-48
lines changed

dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/UrlInstrumentation.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public UrlInstrumentation() {
2525
super("urlconnection", "httpurlconnection");
2626
}
2727

28+
@Override
29+
protected boolean defaultEnabled() {
30+
return false;
31+
}
32+
2833
@Override
2934
public String instrumentedType() {
3035
return "java.net.URL";

dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import datadog.trace.agent.test.naming.VersionedNamingTestBase
22
import datadog.trace.api.DDSpanTypes
33
import datadog.trace.bootstrap.DatadogClassLoader
44
import datadog.trace.bootstrap.instrumentation.api.Tags
5-
import datadog.trace.bootstrap.instrumentation.decorator.UrlConnectionDecorator
65

76
import static datadog.trace.agent.test.utils.PortUtils.UNUSABLE_PORT
87
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
@@ -68,53 +67,6 @@ abstract class UrlConnectionTest extends VersionedNamingTestBase {
6867
url = new URI("$scheme://localhost:$UNUSABLE_PORT").toURL()
6968
}
7069

71-
def "trace request with connection failure to a local file with broken url path"() {
72-
setup:
73-
def url = new URI("file:/some-random-file%abc").toURL()
74-
75-
when:
76-
injectSysConfig(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "$renameService")
77-
runUnderTrace("someTrace") {
78-
url.openConnection()
79-
}
80-
81-
then:
82-
thrown IllegalArgumentException
83-
84-
expect:
85-
assertTraces(1) {
86-
trace(2) {
87-
span {
88-
operationName "someTrace"
89-
parent()
90-
errored true
91-
tags {
92-
errorTags IllegalArgumentException, String
93-
defaultTags()
94-
}
95-
}
96-
span {
97-
operationName operation(url.protocol)
98-
resourceName "$url.path"
99-
spanType DDSpanTypes.HTTP_CLIENT
100-
childOf span(0)
101-
errored true
102-
tags {
103-
"$Tags.COMPONENT" UrlConnectionDecorator.COMPONENT
104-
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
105-
// FIXME: These tags really make no sense for non-http connections, why do we set them?
106-
"$Tags.HTTP_URL" "$url"
107-
errorTags IllegalArgumentException, String
108-
defaultTagsNoPeerService()
109-
}
110-
}
111-
}
112-
}
113-
114-
where:
115-
renameService << [false, true]
116-
}
117-
11870
def "DatadogClassloader ClassNotFoundException doesn't create span"() {
11971
given:
12072
ClassLoader datadogLoader = new DatadogClassLoader()

0 commit comments

Comments
 (0)