Unified http status code usage (#3239)

* Unified http status code usage

* fmt
This commit is contained in:
于玉桔 2019-08-10 18:17:17 +08:00 committed by 吴晟 Wu Sheng
parent 73cf05c5b9
commit 8611124b33
4 changed files with 7 additions and 6 deletions

View File

@ -114,7 +114,7 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, statusCode + "");
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
}

View File

@ -49,8 +49,8 @@ public class HttpAsyncResponseConsumerWrapper<T> implements HttpAsyncResponseCon
public void responseReceived(HttpResponse response) throws IOException, HttpException {
if (ContextManager.isActive()) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode > 400) {
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
AbstractSpan span = ContextManager.activeSpan().errorOccurred();
Tags.STATUS_CODE.set(span, String.valueOf(statusCode));
}
ContextManager.stopSpan();

View File

@ -18,19 +18,20 @@
package org.apache.skywalking.apm.plugin.spring.webflux.v5;
import io.netty.handler.codec.http.HttpResponseStatus;
import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import java.lang.reflect.Method;
public class StatusInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
HttpResponseStatus status = (HttpResponseStatus)allArguments[0];
if (status.code() > 400) {
if (status.code() >= 400) {
ContextManager.activeSpan().errorOccurred();
Tags.STATUS_CODE.set(ContextManager.activeSpan(), String.valueOf(status.code()));
}

View File

@ -42,7 +42,7 @@ public class HttpClientOperationsStatusInterceptor implements InstanceMethodsAro
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
HttpResponseStatus response = (HttpResponseStatus) ret;
if (response.code() > 400) {
if (response.code() >= 400) {
ContextManager.activeSpan().errorOccurred();
Tags.STATUS_CODE.set(ContextManager.activeSpan(), String.valueOf(response.code()));
}