PrintTraceIdInterceptor.java 1.1 KB
Newer Older
P
pengys5 已提交
1 2
package org.skywalking.apm.toolkit.activation.log.log4j.v1.x;

3
import org.skywalking.apm.agent.core.context.ContextManager;
4
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
5 6
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
P
pengys5 已提交
7 8 9 10 11

/**
 * Created by wusheng on 2016/12/7.
 */
public class PrintTraceIdInterceptor implements InstanceMethodsAroundInterceptor {
12 13 14

    @Override public void beforeMethod(EnhancedInstance objInst, String methodName, Object[] allArguments,
        Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
P
pengys5 已提交
15 16 17

    }

18 19
    @Override public Object afterMethod(EnhancedInstance objInst, String methodName, Object[] allArguments,
        Class<?>[] argumentsTypes, Object ret) throws Throwable {
P
pengys5 已提交
20 21 22
        return "TID:" + ContextManager.getGlobalTraceId();
    }

23 24
    @Override public void handleMethodException(EnhancedInstance objInst, String methodName, Object[] allArguments,
        Class<?>[] argumentsTypes, Throwable t) {
P
pengys5 已提交
25 26 27

    }
}