Search in sources :

Example 1 with BurlapServlet

use of com.caucho.burlap.server.BurlapServlet in project LinkAgent by shulieTech.

the class BurlapServletServiceInterceptor 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);
    BurlapServlet burlapServlet = (BurlapServlet) target;
    BurlapSkeleton hessianSkeleton = null;
    try {
        hessianSkeleton = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_SKELETON);
    } catch (ReflectException e) {
    }
    Object[] result = getMethodArgs(request.getInputStream(), hessianSkeleton);
    Object[] arguments = (Object[]) result[1];
    if (method == null) {
        method = (String) result[0];
    }
    Class<?> clazz = null;
    try {
        clazz = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_TYPE);
    } catch (ReflectException e) {
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(clazz == null ? null : clazz.getName());
    spanRecord.setMethod(method);
    spanRecord.setRequest(arguments);
    spanRecord.setPort(request.getRemotePort());
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BurlapServlet(com.caucho.burlap.server.BurlapServlet) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest) BurlapSkeleton(com.caucho.burlap.server.BurlapSkeleton) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Aggregations

BurlapServlet (com.caucho.burlap.server.BurlapServlet)1 BurlapSkeleton (com.caucho.burlap.server.BurlapSkeleton)1 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)1 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)1 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)1 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1