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;
}
Aggregations