Search in sources :

Example 56 with SpanRecord

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

the class HttpClientv5MethodInterceptor1 method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    HttpRequest request = (HttpRequest) args[0];
    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());
    try {
        record.setRequest(getParameters(request));
    } catch (Throwable e) {
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) SocketTimeoutException(java.net.SocketTimeoutException) JSONObject(com.alibaba.fastjson.JSONObject)

Example 57 with SpanRecord

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

the class BurlapServletServiceInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    Class<?> type = getType(target, args);
    if (type == null) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 58 with SpanRecord

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

the class HessianServiceExporterHandleRequestInterceptor method afterTrace.

@Override
public SpanRecord afterTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method == null) {
        method = Pradar.getMethod();
    }
    if (method != null && isSkip(method)) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest)

Example 59 with SpanRecord

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

the class HessianServiceExporterHandleRequestInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method == null) {
        method = Pradar.getMethod();
    }
    if (method != null && isSkip(method)) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest)

Example 60 with SpanRecord

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

the class HessianServiceExporterHandleRequestInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method != null && isSkip(method)) {
        return null;
    }
    HessianServiceExporter serviceExporter = (HessianServiceExporter) target;
    HessianSkeleton hessianSkeleton = null;
    try {
        hessianSkeleton = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_OBJECT_SKELETON);
    } catch (ReflectException e) {
    }
    SerializerFactory serializerFactory = null;
    try {
        serializerFactory = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_SERIALIZER_FACTORY);
    } catch (ReflectException e) {
    }
    Object[] result = getMethodArgs(request.getInputStream(), serializerFactory, hessianSkeleton);
    Object[] arguments = (Object[]) result[1];
    if (method == null) {
        method = (String) result[0];
    }
    Class<?> clazz = serviceExporter.getServiceInterface();
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(clazz.getName());
    spanRecord.setMethod(method);
    spanRecord.setRequest(arguments);
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest) HessianSkeleton(com.caucho.hessian.server.HessianSkeleton) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) HessianServiceExporter(org.springframework.remoting.caucho.HessianServiceExporter)

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