Skip to content

Commit

Permalink
Disable URL instrumentation by default
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
mcculls committed May 24, 2024
1 parent 2d6803a commit 1ae652a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public UrlInstrumentation() {
super("urlconnection", "httpurlconnection");
}

@Override
protected boolean defaultEnabled() {
return false;
}

@Override
public String instrumentedType() {
return "java.net.URL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import datadog.trace.agent.test.naming.VersionedNamingTestBase
import datadog.trace.api.DDSpanTypes
import datadog.trace.bootstrap.DatadogClassLoader
import datadog.trace.bootstrap.instrumentation.api.Tags
import datadog.trace.bootstrap.instrumentation.decorator.UrlConnectionDecorator

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

def "trace request with connection failure to a local file with broken url path"() {
setup:
def url = new URI("file:/some-random-file%abc").toURL()

when:
injectSysConfig(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "$renameService")
runUnderTrace("someTrace") {
url.openConnection()
}

then:
thrown IllegalArgumentException

expect:
assertTraces(1) {
trace(2) {
span {
operationName "someTrace"
parent()
errored true
tags {
errorTags IllegalArgumentException, String
defaultTags()
}
}
span {
operationName operation(url.protocol)
resourceName "$url.path"
spanType DDSpanTypes.HTTP_CLIENT
childOf span(0)
errored true
tags {
"$Tags.COMPONENT" UrlConnectionDecorator.COMPONENT
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
// FIXME: These tags really make no sense for non-http connections, why do we set them?
"$Tags.HTTP_URL" "$url"
errorTags IllegalArgumentException, String
defaultTagsNoPeerService()
}
}
}
}

where:
renameService << [false, true]
}

def "DatadogClassloader ClassNotFoundException doesn't create span"() {
given:
ClassLoader datadogLoader = new DatadogClassLoader()
Expand Down

0 comments on commit 1ae652a

Please sign in to comment.