use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class AbstractCommonTraceInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
SpanRecord record = new SpanRecord();
record.setMethod(advice.getBehaviorName());
record.setResponse(advice.getReturnObj());
record.setClusterTest(Pradar.isClusterTest());
record.setService(advice.getTarget().getClass().getName());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class AbstractCommonTraceInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
SpanRecord record = new SpanRecord();
record.setMethod(advice.getBehaviorName());
record.setRequest(advice.getParameterArray());
record.setClusterTest(Pradar.isClusterTest());
record.setService(advice.getTarget().getClass().getName());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv3MethodInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
final HttpMethod method = (HttpMethod) args[1];
if (method == null) {
return null;
}
InnerWhiteListCheckUtil.check();
try {
SpanRecord record = new SpanRecord();
int port = method.getURI().getPort();
record.setService(method.getURI().getPath());
record.setMethod(StringUtils.upperCase(method.getName()));
Header header = method.getRequestHeader("content-length");
if (header != null && StringUtils.isNotBlank(header.getValue())) {
try {
record.setRequestSize(Integer.valueOf(header.getValue()));
} catch (NumberFormatException e) {
}
}
if ("get".equals(record.getMethod()) || "GET".equals(record.getMethod()) || "head".equals(record.getMethod()) || "HEAD".equals(record.getMethod())) {
record.setRequest(toMap(method.getQueryString()));
} else {
Map parameters = new HashMap();
buildParameters(method.getParams(), parameters);
parameters.putAll(toMap(method.getQueryString()));
record.setRequest(parameters);
}
record.setMiddlewareName(HttpClientConstants.HTTP_CLIENT_NAME_3X);
record.setRemoteIp(method.getURI().getHost());
record.setPort(port);
return record;
} catch (URIException e) {
return null;
}
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv3MethodInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpMethod method = (HttpMethod) args[1];
if (method == null) {
return null;
}
try {
SpanRecord record = new SpanRecord();
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
record.setRequest(method.getParams());
record.setResponse(advice.getThrowable());
InnerWhiteListCheckUtil.check();
// record.setResponseSize(method.getResponseBody() == null ? 0 : method.getResponseBody().length);
return record;
} catch (Throwable e) {
Pradar.responseSize(0);
}
return null;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv3MethodInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpMethod method = (HttpMethod) args[1];
if (method == null) {
return null;
}
try {
SpanRecord record = new SpanRecord();
Integer code = (Integer) advice.getReturnObj();
String msg = method.getURI().toString() + "->" + code;
record.setResultCode(code + "");
record.setResponse(msg);
InnerWhiteListCheckUtil.check();
// record.setResponseSize(method.getResponseBody() == null ? 0 : method.getResponseBody().length);
return record;
} catch (Throwable e) {
Pradar.responseSize(0);
}
return null;
}
Aggregations