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