提交 af16ece5 编写于 作者: X Xin,Zhang 提交者: wu-sheng

[Agent] fix trace can't finished when the StatusLine isn't set (#945)

上级 08267611
......@@ -24,6 +24,7 @@ import java.net.URL;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
......@@ -77,13 +78,15 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
}
HttpResponse response = (HttpResponse)ret;
int statusCode = response.getStatusLine().getStatusCode();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
StatusLine responseStatusLine = response.getStatusLine();
if (responseStatusLine != null) {
int statusCode = responseStatusLine.getStatusCode();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
}
ContextManager.stopSpan();
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册