use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class AsyncHbaseMethodInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
HBaseRpc request = (HBaseRpc) advice.getParameterArray()[0];
SpanRecord record = new SpanRecord();
getRequest(request, record);
record.setRequest(request.toString());
if (advice.getReturnObj() != null) {
record.setResponse(advice.getReturnObj().toString());
}
record.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return new SpanRecord();
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class CacheOperationTraceInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
String methodName = advice.getBehaviorName();
Object target = advice.getTarget();
SpanRecord record = new SpanRecord();
record.setService(target.getClass().getName());
record.setMethod(methodName);
record.setRequest(args);
record.setResponse(advice.getThrowable());
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ServerStreamCreatedInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object result = advice.getReturnObj();
if (!validate(args)) {
return null;
}
SpanRecord record = new SpanRecord();
record.setResponse(result);
record.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ServerStreamCreatedInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (!validate(args)) {
return null;
}
SpanRecord record = new SpanRecord();
record.setResponse(advice.getThrowable());
if (advice.getThrowable() instanceof SocketTimeoutException) {
record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
} else {
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ServerStreamListenerImplHalfClosedInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
final String fullMethodName = manager.getDynamicField(advice.getTarget(), GrpcConstants.DYNAMIC_FIELD_FULL_METHOD_NAME);
final Map<String, String> invokeContext = manager.getDynamicField(advice.getTarget(), GrpcConstants.DYNAMIC_FIELD_INVOKE_CONTEXT);
SpanRecord record = new SpanRecord();
String rpcId = invokeContext.get(Pradar.getInvokeIdKey());
String[] rpcIds = rpcId.split("\\.");
String lastRpcId = Integer.valueOf(rpcIds[rpcIds.length - 1]) + 1 + "";
StringBuilder newRpcId = new StringBuilder();
for (int i = 0; i < rpcIds.length - 1; i++) {
newRpcId.append(rpcIds[i]).append(".");
}
newRpcId.append(lastRpcId);
invokeContext.put(Pradar.getInvokeIdKey(), newRpcId.toString());
record.setContext(invokeContext);
String method = fullMethodName;
String service = "";
if (fullMethodName.indexOf("/") != -1) {
service = fullMethodName.substring(0, fullMethodName.lastIndexOf("/"));
method = fullMethodName.substring(fullMethodName.lastIndexOf("/") + 1);
}
record.setMethod(method);
record.setService(service);
return record;
}
Aggregations