Use connect operationName in httpurlconnection connect-first case
This commit is contained in:
parent
54485c3296
commit
ee594f8567
|
@ -81,6 +81,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
@Advice.Origin("#m") final String methodName) {
|
@Advice.Origin("#m") final String methodName) {
|
||||||
|
|
||||||
final HttpURLState state = HttpURLState.get(thiz);
|
final HttpURLState state = HttpURLState.get(thiz);
|
||||||
|
String operationName = "http.request";
|
||||||
if ("connect".equals(methodName)) {
|
if ("connect".equals(methodName)) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -91,6 +92,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
// In total there will be two spans:
|
// In total there will be two spans:
|
||||||
// - one for the connect() which does propagation
|
// - one for the connect() which does propagation
|
||||||
// - one for the input or output stream (presumably called after connect())
|
// - one for the input or output stream (presumably called after connect())
|
||||||
|
operationName += ".connect";
|
||||||
} else {
|
} else {
|
||||||
if (state.hasDoneIO()) {
|
if (state.hasDoneIO()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,8 +100,10 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
state.setHasDoneIO(true);
|
state.setHasDoneIO(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AgentWriter uses HttpURLConnection to report to the trace-agent. We don't want to trace those requests.
|
// AgentWriter uses HttpURLConnection to report to the trace-agent. We don't want to trace
|
||||||
// Check after the connected test above because getRequestProperty will throw an exception if already connected.
|
// those requests.
|
||||||
|
// Check after the connected test above because getRequestProperty will throw an exception if
|
||||||
|
// already connected.
|
||||||
final boolean isTraceRequest =
|
final boolean isTraceRequest =
|
||||||
Thread.currentThread().getName().equals("dd-agent-writer")
|
Thread.currentThread().getName().equals("dd-agent-writer")
|
||||||
|| (!connected && thiz.getRequestProperty("Datadog-Meta-Lang") != null);
|
|| (!connected && thiz.getRequestProperty("Datadog-Meta-Lang") != null);
|
||||||
|
@ -120,7 +124,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
final Scope scope =
|
final Scope scope =
|
||||||
tracer
|
tracer
|
||||||
.buildSpan("http.request")
|
.buildSpan(operationName)
|
||||||
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
|
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
|
||||||
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
|
.withTag(DDTags.SPAN_TYPE, DDSpanTypes.HTTP_CLIENT)
|
||||||
.startActive(true);
|
.startActive(true);
|
||||||
|
@ -160,7 +164,8 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||||
} else if (responseCode > 0) {
|
} else if (responseCode > 0) {
|
||||||
// responseCode field cache is sometimes not populated.
|
// responseCode field cache is sometimes not populated.
|
||||||
// We can't call getResponseCode() due to some unwanted side-effects (e.g. breaks getOutputStream).
|
// We can't call getResponseCode() due to some unwanted side-effects (e.g. breaks
|
||||||
|
// getOutputStream).
|
||||||
Tags.HTTP_STATUS.set(span, responseCode);
|
Tags.HTTP_STATUS.set(span, responseCode);
|
||||||
}
|
}
|
||||||
scope.close();
|
scope.close();
|
||||||
|
|
|
@ -392,7 +392,7 @@ class HttpUrlConnectionTest extends AgentTestRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
span(2) {
|
span(2) {
|
||||||
operationName "http.request"
|
operationName "http.request.connect"
|
||||||
childOf span(0)
|
childOf span(0)
|
||||||
errored false
|
errored false
|
||||||
tags {
|
tags {
|
||||||
|
|
Loading…
Reference in New Issue