use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.
the class HessianServletServiceInterceptor 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);
HessianServlet hessianServlet = (HessianServlet) target;
String objectId = request.getParameter("id");
if (objectId == null) {
objectId = request.getParameter("ejbid");
}
HessianSkeleton hessianSkeleton = null;
try {
hessianSkeleton = Reflect.on(hessianServlet).get(HessianConstants.DYNAMIC_FIELD_OBJECT_SKELETON);
} catch (ReflectException e) {
try {
hessianSkeleton = Reflect.on(hessianServlet).get(HessianConstants.DYNAMIC_FIELD_HOME_SKELETON);
} catch (ReflectException reflectException) {
}
}
Object[] result = getMethodArgs(request.getInputStream(), hessianServlet.getSerializerFactory(), hessianSkeleton);
Object[] arguments = (Object[]) result[1];
if (method == null) {
method = (String) result[0];
}
Class<?> clazz = hessianServlet.getAPIClass();
SpanRecord spanRecord = new SpanRecord();
spanRecord.setService(clazz.getName());
spanRecord.setMethod(method);
spanRecord.setRequest(arguments);
return spanRecord;
}
Aggregations