Remove getResponseCode() from httpurlconneciton instrumentation
This commit is contained in:
parent
2a35ecb497
commit
df95af53a7
|
@ -19,7 +19,6 @@ import io.opentracing.Tracer;
|
||||||
import io.opentracing.propagation.Format;
|
import io.opentracing.propagation.Format;
|
||||||
import io.opentracing.tag.Tags;
|
import io.opentracing.tag.Tags;
|
||||||
import io.opentracing.util.GlobalTracer;
|
import io.opentracing.util.GlobalTracer;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -129,7 +128,7 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void stopSpan(
|
public static void stopSpan(
|
||||||
@Advice.This final HttpURLConnection thiz,
|
@Advice.FieldValue("responseCode") final int responseCode,
|
||||||
@Advice.Enter final Scope scope,
|
@Advice.Enter final Scope scope,
|
||||||
@Advice.Thrown final Throwable throwable) {
|
@Advice.Thrown final Throwable throwable) {
|
||||||
|
|
||||||
|
@ -142,12 +141,10 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||||
Tags.ERROR.set(span, true);
|
Tags.ERROR.set(span, true);
|
||||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||||
} else {
|
} else {
|
||||||
try {
|
if (responseCode > 0) {
|
||||||
// response code field is sometimes not populated until the getResponseCode method is explicitly called.
|
// responseCode field cache is sometimes not populated.
|
||||||
// Calling getResponseCode() here will not trigger additional instrumentation because we have not reset the depth map.
|
// We can't call getResponseCode() due to some unwanted side-effects (e.g. breaks getOutputStream).
|
||||||
Tags.HTTP_STATUS.set(span, thiz.getResponseCode());
|
Tags.HTTP_STATUS.set(span, responseCode);
|
||||||
} catch (IOException ioe) {
|
|
||||||
// ignore
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scope.close();
|
scope.close();
|
||||||
|
|
Loading…
Reference in New Issue