Don't trace httpurlconnection as a top-level trace
This commit is contained in:
parent
d598515d09
commit
54485c3296
|
@ -107,12 +107,17 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Tracer tracer = GlobalTracer.get();
|
||||||
|
if (tracer.activeSpan() == null) {
|
||||||
|
// httpurlconnection doesn't play nicely with top-level spans
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(HttpURLConnection.class);
|
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(HttpURLConnection.class);
|
||||||
if (callDepth > 0) {
|
if (callDepth > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tracer tracer = GlobalTracer.get();
|
|
||||||
final Scope scope =
|
final Scope scope =
|
||||||
tracer
|
tracer
|
||||||
.buildSpan("http.request")
|
.buildSpan("http.request")
|
||||||
|
|
|
@ -332,6 +332,20 @@ class HttpUrlConnectionTest extends AgentTestRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "top level httpurlconnection tracing disabled"() {
|
||||||
|
setup:
|
||||||
|
HttpURLConnection connection = server.address.toURL().openConnection()
|
||||||
|
connection.addRequestProperty("is-dd-server", "false")
|
||||||
|
def stream = connection.inputStream
|
||||||
|
def lines = stream.readLines()
|
||||||
|
stream.close()
|
||||||
|
assert connection.getResponseCode() == STATUS
|
||||||
|
assert lines == [RESPONSE]
|
||||||
|
|
||||||
|
expect:
|
||||||
|
assertTraces(TEST_WRITER, 0) {}
|
||||||
|
}
|
||||||
|
|
||||||
def "rest template"() {
|
def "rest template"() {
|
||||||
setup:
|
setup:
|
||||||
runUnderTrace("someTrace") {
|
runUnderTrace("someTrace") {
|
||||||
|
|
Loading…
Reference in New Issue