Search in sources :

Example 11 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class TransportClientTraceInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Throwable throwable = advice.getThrowable();
    SpanRecord record = new SpanRecord();
    record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    record.setRequest(args[1]);
    record.setResponse(throwable);
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 12 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class HessianProxyWrapper method exceptionTrace.

public SpanRecord exceptionTrace(Object target, String methodName, Method method, Object[] args, Throwable throwable) {
    if (args == null || args.length == 0) {
        return null;
    }
    Class<?> type = getType(target, method, args);
    if (type == null) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(type.getName());
    spanRecord.setMethod(method.getName());
    spanRecord.setRequest(args);
    spanRecord.setResponse(throwable);
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    URL url = null;
    try {
        url = Reflect.on(target).get(HessianConstants.DYNAMIC_FIELD_URL);
    } catch (ReflectException e) {
    }
    if (url != null) {
        String host = url.getHost();
        int port = url.getPort();
        if (port == 80 || port == -1) {
            host = host + ":" + port;
        }
        spanRecord.setRemoteIp(host);
    }
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) URL(java.net.URL)

Example 13 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class HessianProxyWrapper method beforeTrace.

public SpanRecord beforeTrace(Object target, String methodName, Method method, Object[] args) {
    if (args == null || args.length == 0) {
        return null;
    }
    Class<?> type = getType(target, method, args);
    if (type == null) {
        return null;
    }
    manager.setDynamicField(target, HessianConstants.DYNAMIC_FIELD_METHOD, method);
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(type.getName());
    spanRecord.setMethod(method.getName());
    spanRecord.setRequest(args);
    URL url = null;
    try {
        url = Reflect.on(target).get(HessianConstants.DYNAMIC_FIELD_URL);
    } catch (ReflectException e) {
    }
    if (url != null) {
        String host = url.getHost();
        int port = url.getPort();
        if (port == 80 || port == -1) {
            host = host + ":" + port;
        }
        spanRecord.setRemoteIp(host);
    }
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) URL(java.net.URL)

Example 14 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class HessianProxyWrapper method afterTrace.

public SpanRecord afterTrace(Object target, String methodName, Method method, Object[] args, Object result) {
    if (args == null || args.length == 0) {
        return null;
    }
    Class<?> type = getType(target, method, args);
    if (type == null) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(type.getName());
    spanRecord.setMethod(method.getName());
    spanRecord.setRequest(args);
    spanRecord.setResponse(result);
    URL url = null;
    try {
        url = Reflect.on(target).get(HessianConstants.DYNAMIC_FIELD_URL);
    } catch (ReflectException e) {
    }
    if (url != null) {
        String host = url.getHost();
        int port = url.getPort();
        if (port == 80 || port == -1) {
            host = host + ":" + port;
        }
        spanRecord.setRemoteIp(host);
    }
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) URL(java.net.URL)

Example 15 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class AliHBaseUETableInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    AliHBaseUETable hTable = (AliHBaseUETable) advice.getTarget();
    SpanRecord spanRecord = new SpanRecord();
    String tableName = getTableName(hTable);
    spanRecord.setService(tableName);
    spanRecord.setMethod(advice.getBehaviorName());
    spanRecord.setRequest(advice.getParameterArray()[0]);
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) AliHBaseUETable(org.apache.hadoop.hbase.client.AliHBaseUETable)

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