use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv4MethodInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpRequest request = (HttpRequest) args[1];
SpanRecord record = new SpanRecord();
InnerWhiteListCheckUtil.check();
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
try {
record.setRequest(getParameters(request));
} catch (Throwable e) {
}
record.setResponse(advice.getThrowable());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv4MethodInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpRequest request = (HttpRequest) args[1];
SpanRecord record = new SpanRecord();
if (advice.getReturnObj() instanceof HttpResponse) {
HttpResponse response = (HttpResponse) advice.getReturnObj();
try {
record.setResponseSize(response == null ? 0 : response.getEntity().getContentLength());
} catch (Throwable e) {
record.setResponseSize(0);
}
int code = response.getStatusLine().getStatusCode();
record.setResultCode(code + "");
}
InnerWhiteListCheckUtil.check();
try {
record.setRequest(getParameters(request));
} catch (Throwable e) {
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv4MethodInterceptor1 method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
final HttpUriRequest request = (HttpUriRequest) args[0];
if (request == null) {
return null;
}
InnerWhiteListCheckUtil.check();
String host = request.getURI().getHost();
int port = request.getURI().getPort();
String path = request.getURI().getPath();
SpanRecord record = new SpanRecord();
record.setService(path);
String method = request.getMethod();
record.setMethod(method);
record.setRemoteIp(host);
record.setPort(port);
record.setMiddlewareName(HttpClientConstants.HTTP_CLIENT_NAME_4X);
Header[] headers = request.getHeaders("content-length");
if (headers != null && headers.length != 0) {
try {
Header header = headers[0];
record.setRequestSize(Integer.valueOf(header.getValue()));
} catch (NumberFormatException e) {
}
}
// OSS 使用httpclient的时候会验证crc,提前读取request的stream流导致crc验证无法通过,先注释
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv5MethodInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpRequest request = (HttpRequest) args[1];
SpanRecord record = new SpanRecord();
if (advice.getReturnObj() instanceof ClassicHttpResponse) {
ClassicHttpResponse response = (ClassicHttpResponse) advice.getReturnObj();
try {
record.setResponseSize(response == null ? 0 : response.getEntity().getContentLength());
} catch (Throwable e) {
record.setResponseSize(0);
}
int code = response.getCode();
record.setResultCode(code + "");
}
try {
record.setRequest(getParameters(request));
} catch (Throwable e) {
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpClientv5MethodInterceptor1 method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
HttpRequest request = (HttpRequest) args[0];
SpanRecord record = new SpanRecord();
if (advice.getReturnObj() instanceof ClassicHttpResponse) {
ClassicHttpResponse response = (ClassicHttpResponse) advice.getReturnObj();
try {
record.setResponseSize(response == null ? 0 : response.getEntity().getContentLength());
} catch (Throwable e) {
record.setResponseSize(0);
}
int code = response.getCode();
record.setResultCode(code + "");
} else {
record.setResponse(advice.getReturnObj());
}
try {
if (request.getHeaders(HeaderMark.DONT_READ_INPUT) == null || request.getHeaders(HeaderMark.DONT_READ_INPUT).length == 0) {
record.setRequest(getParameters(request));
}
} catch (Throwable e) {
}
return record;
}
Aggregations