use of com.shulie.instrument.simulator.module.stack.trace.util.TraceInfo in project LinkAgent by shulieTech.
the class TraceListener method afterReturning.
@Override
public void afterReturning(Advice advice) throws Throwable {
Object resultObj = advice.getReturnObj();
Throwable throwable = advice.getThrowable();
TraceView traceView = traceViewThreadLocal.get();
if (throwable != null) {
traceView.getCurrent().setErrorMsg(ResultSerializer.serializeObject(throwable, 2));
} else if (resultObj != null) {
traceView.getCurrent().setResult(ResultSerializer.serializeObject(resultObj, 2));
}
if (traceView.currentIsRoot()) {
traceView.setTotalCost(traceView.getRootCost());
traceView.setClassloader(traceView.getRoot() == null ? null : traceView.getRoot().getClassloader());
TraceInfo traceInfo = ThreadUtil.getTraceInfo(Thread.currentThread());
if (traceInfo != null) {
traceView.setClusterTestAfter(traceInfo.isClusterTest());
}
rootTrace(advice, traceView);
traceViewThreadLocal.remove();
} else {
traceView.end();
}
}
use of com.shulie.instrument.simulator.module.stack.trace.util.TraceInfo in project LinkAgent by shulieTech.
the class TraceListener method before.
@Override
public void before(Advice advice) throws Throwable {
TraceView traceView;
if ((traceView = traceViewThreadLocal.get()) == null) {
traceView = new TraceView(advice.getTargetClass().getName(), advice.getBehavior().getName(), advice.getClassLoader().toString());
TraceInfo traceInfo = ThreadUtil.getTraceInfo(Thread.currentThread());
if (traceInfo != null) {
traceView.setTraceId(traceInfo.getTraceId());
traceView.setRpcId(traceInfo.getRpcId());
traceView.setClusterTestBefore(traceInfo.isClusterTest());
}
Object[] args = advice.getParameterArray();
// beforeCall在这之前调用,已经设置了current了
traceView.getCurrent().setArgs(ResultSerializer.serializeObject(args, 2));
traceViewThreadLocal.set(traceView);
} else {
if (traceView.getCurrent().getClassName().equals(advice.getTargetClass().getName()) && traceView.getCurrent().getMethodName().equals(advice.getBehavior().getName()) && StackEvent.LINE_CALL.equals(traceView.lastStage())) {
traceView.appendMethodCall();
} else {
traceView.begin(advice.getTargetClass().getName(), advice.getBehavior().getName(), advice.getClassLoader().toString(), StackEvent.METHOD_CALL);
}
}
Object[] args = advice.getParameterArray();
// beforeCall在这之前调用,已经设置了current了
traceView.getCurrent().setArgs(ResultSerializer.serializeObject(args, 2));
}