From 1ae652ab66eb2b10106a18ad61e223d92cd7db5d Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Fri, 24 May 2024 12:49:16 +0100 Subject: [PATCH] Disable URL instrumentation by default 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` --- .../UrlInstrumentation.java | 5 ++ .../src/test/groovy/UrlConnectionTest.groovy | 48 ------------------- 2 files changed, 5 insertions(+), 48 deletions(-) diff --git a/dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/UrlInstrumentation.java b/dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/UrlInstrumentation.java index 18007fba8f2..9af40e56587 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/UrlInstrumentation.java +++ b/dd-java-agent/instrumentation/http-url-connection/src/main/java/datadog/trace/instrumentation/http_url_connection/UrlInstrumentation.java @@ -25,6 +25,11 @@ public UrlInstrumentation() { super("urlconnection", "httpurlconnection"); } + @Override + protected boolean defaultEnabled() { + return false; + } + @Override public String instrumentedType() { return "java.net.URL"; diff --git a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy index dbd521fa80c..8ba15a044dd 100644 --- a/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy +++ b/dd-java-agent/instrumentation/http-url-connection/src/test/groovy/UrlConnectionTest.groovy @@ -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 @@ -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()