Search in sources :

Example 16 with SpanRecord

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();
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 17 with 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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 18 with SpanRecord

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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 19 with SpanRecord

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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) SocketTimeoutException(java.net.SocketTimeoutException)

Example 20 with SpanRecord

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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Aggregations

SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)199 JSONObject (com.alibaba.fastjson.JSONObject)19 SocketTimeoutException (java.net.SocketTimeoutException)15 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)13 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)11 HashMap (java.util.HashMap)10 List (java.util.List)8 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)6 Request (com.weibo.api.motan.rpc.Request)6 HeaderProcessor (com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor)5 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)5 URI (java.net.URI)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Metadata (io.grpc.Metadata)4 ServerAddress (com.mongodb.ServerAddress)3 Channel (com.rabbitmq.client.Channel)3 Connection (com.rabbitmq.client.Connection)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 URL (java.net.URL)3