use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class RealCallEnqueueV2Interceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
InnerWhiteListCheckUtil.check();
Object target = advice.getTarget();
Request request = null;
try {
request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_REQUEST);
} catch (ReflectException e) {
request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_ORIGINAL_REQUEST);
}
SpanRecord record = new SpanRecord();
record.setRemoteIp(request.url().getHost());
record.setPort(request.url().getPort());
record.setService(request.url().getPath());
record.setMethod(StringUtils.upperCase(request.method()));
record.setRequest(request.url().getQuery());
String header = request.header("content-length");
if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
try {
record.setRequestSize(Integer.valueOf(header));
} catch (NumberFormatException e) {
}
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class RealCallExecuteV2Interceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
SpanRecord record = new SpanRecord();
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
record.setResponse(advice.getThrowable());
record.setResponseSize(0);
InnerWhiteListCheckUtil.check();
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class RealCallExecuteV2Interceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
InnerWhiteListCheckUtil.check();
Object target = advice.getTarget();
Request request = null;
try {
request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_REQUEST);
} catch (ReflectException e) {
request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_ORIGINAL_REQUEST);
}
SpanRecord record = new SpanRecord();
record.setRemoteIp(request.url().getHost());
record.setService(request.url().getPath());
record.setMethod(StringUtils.upperCase(request.method()));
record.setRemoteIp(request.url().getHost());
record.setPort(request.url().getPort());
record.setRequest(request.url().getQuery());
String header = request.header("content-length");
if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
try {
record.setRequestSize(Integer.valueOf(header));
} catch (NumberFormatException e) {
}
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class RealCallExecuteV3Interceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object target = advice.getTarget();
Call call = (Call) target;
SpanRecord record = new SpanRecord();
HttpUrl url = call.request().url();
record.setRemoteIp(url.host());
record.setService(url.encodedPath());
record.setMethod(StringUtils.upperCase(call.request().method()));
record.setRemoteIp(url.host());
record.setPort(url.port());
record.setRequest(url.encodedQuery());
String header = call.request().header("content-length");
if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
try {
record.setRequestSize(Integer.valueOf(header));
} catch (NumberFormatException e) {
}
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class RealCallExecuteV3Interceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
SpanRecord record = new SpanRecord();
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
record.setResponse(advice.getThrowable());
record.setResponseSize(0);
InnerWhiteListCheckUtil.check();
return record;
}
Aggregations