Search in sources :

Example 1 with TraceView

use of com.shulie.instrument.simulator.module.model.trace2.TraceView 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();
    }
}
Also used : TraceView(com.shulie.instrument.simulator.module.model.trace2.TraceView) TraceInfo(com.shulie.instrument.simulator.module.stack.trace.util.TraceInfo)

Example 2 with TraceView

use of com.shulie.instrument.simulator.module.model.trace2.TraceView 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));
}
Also used : TraceView(com.shulie.instrument.simulator.module.model.trace2.TraceView) TraceInfo(com.shulie.instrument.simulator.module.stack.trace.util.TraceInfo)

Example 3 with TraceView

use of com.shulie.instrument.simulator.module.model.trace2.TraceView in project LinkAgent by shulieTech.

the class TraceListener method afterCallThrowing.

@Override
public void afterCallThrowing(final Advice advice, final int callLineNum, final boolean isInterface, final String callJavaClassName, final String callJavaMethodName, final String callJavaMethodDesc, final Throwable callThrowable) {
    TraceView traceView = traceViewThreadLocal.get();
    traceView.getCurrent().setErrorMsg(ResultSerializer.serializeObject(callThrowable, 2));
    traceView.end();
}
Also used : TraceView(com.shulie.instrument.simulator.module.model.trace2.TraceView)

Example 4 with TraceView

use of com.shulie.instrument.simulator.module.model.trace2.TraceView in project LinkAgent by shulieTech.

the class TraceListener method beforeCall.

@Override
public void beforeCall(final Advice advice, final int callLineNum, final boolean isInterface, final String callJavaClassName, final String callJavaMethodName, final String callJavaMethodDesc) {
    TraceView traceView = traceViewThreadLocal.get();
    traceView.begin(callJavaClassName, callJavaMethodName, advice.getClassLoader().toString(), StackEvent.LINE_CALL).setLine(callLineNum);
// addNextLevelTrace(traceView.getCurrent());
}
Also used : TraceView(com.shulie.instrument.simulator.module.model.trace2.TraceView)

Example 5 with TraceView

use of com.shulie.instrument.simulator.module.model.trace2.TraceView in project LinkAgent by shulieTech.

the class TraceListener method afterCallReturning.

@Override
public void afterCallReturning(final Advice advice, final int callLineNum, final boolean isInterface, final String callJavaClassName, final String callJavaMethodName, final String callJavaMethodDesc) {
    // afterReturning有可能在这之前调用,已经设置了current了
    TraceView traceView = traceViewThreadLocal.get();
    traceView.end();
}
Also used : TraceView(com.shulie.instrument.simulator.module.model.trace2.TraceView)

Aggregations

TraceView (com.shulie.instrument.simulator.module.model.trace2.TraceView)6 TraceInfo (com.shulie.instrument.simulator.module.stack.trace.util.TraceInfo)2 Command (com.shulie.instrument.simulator.api.annotation.Command)1 EventWatchBuilder (com.shulie.instrument.simulator.api.listener.ext.EventWatchBuilder)1 EventWatcher (com.shulie.instrument.simulator.api.listener.ext.EventWatcher)1 ModuleEventWatcher (com.shulie.instrument.simulator.api.resource.ModuleEventWatcher)1 ConcurrentHashSet (com.shulie.instrument.simulator.module.stack.trace.util.ConcurrentHashSet)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Queue (java.util.Queue)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1