Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,11 +56,9 @@ public AmazonWebServiceRequest beforeMarshalling(final AmazonWebServiceRequest r
/** {@inheritDoc} */
@Override
public void beforeRequest(final Request<?> request) {
// Note: not setting Component tag here because it is always set by SpanDecorator
final Tracer.SpanBuilder spanBuilder =
tracer
.buildSpan("aws.command")
.withTag(Tags.COMPONENT.getKey(), "aws-sdk")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops... I missed that it was already being set. Nice catch.

.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
tracer.buildSpan("aws.command").withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);

if (parentContext != null) {
spanBuilder.asChildOf(parentContext);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,8 @@
@AutoService(Instrumenter.class)
public class UrlInstrumentation extends Instrumenter.Default {

public static final String COMPONENT = "UrlConnection";

public UrlInstrumentation() {
super("urlconnection", "httpurlconnection");
}
Expand DownExpand Up@@ -67,7 +69,7 @@ public static void errorSpan(
.buildSpan(protocol + ".request")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
.withTag(Tags.COMPONENT.getKey(), "UrlConnection")
.withTag(Tags.COMPONENT.getKey(), COMPONENT)
.startActive(true);

final Span span = scope.span();
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.agent.test.TestUtils
import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.instrumentation.http_url_connection.UrlInstrumentation
import io.opentracing.tag.Tags
import io.opentracing.util.GlobalTracer

Expand DownExpand Up@@ -65,4 +66,47 @@ class UrlConnectionTest extends AgentTestRunner {

url = new URI("$scheme://localhost:$INVALID_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:
runUnderTrace("someTrace") {
url.openConnection()
}

then:
thrown IllegalArgumentException

expect:
assertTraces(1) {
trace(0, 2) {
span(0) {
operationName "someTrace"
parent()
errored true
tags {
errorTags IllegalArgumentException, String
defaultTags()
}
}
span(1) {
operationName "file.request"
childOf span(0)
errored true
tags {
"$Tags.COMPONENT.key" UrlInstrumentation.COMPONENT
"$Tags.SPAN_KIND.key" Tags.SPAN_KIND_CLIENT
// FIXME: These tags really make no sense for non-http connections, why do we set them?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right... it doesn't make sense for this case. perhaps we should limit this error span somehow to http only?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My impression is that http case doesn't even hit this code since we instrument http stuff separately...

"$DDTags.SPAN_TYPE" DDSpanTypes.HTTP_CLIENT
"$Tags.HTTP_URL.key" "$url"
"$Tags.PEER_PORT.key" 80
errorTags IllegalArgumentException, String
defaultTags()
}
}
}
}
}
}