Skip to content

Commit

Permalink
SkyWalking 源码分析 —— @trace 注解想要追踪的任何方法
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Jan 9, 2018
1 parent e4bfdfa commit 9ee7c47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

package org.skywalking.apm.plugin.spring.patch;

import java.lang.reflect.Method;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.springframework.aop.framework.AdvisedSupport;

import java.lang.reflect.Method;

/**
* {@link CreateAopProxyInterceptor} check that the bean has been implement {@link EnhancedInstance}. <p/>
* if yes, true will be returned.
Expand All @@ -42,7 +43,7 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
AdvisedSupport advisedSupport = (AdvisedSupport)allArguments[0];

// 若实现接口,返回 true ,参见 `DefaultAopProxyFactory#hasNoUserSuppliedProxyInterfaces(AdvisedSupport)` 方法
if (EnhancedInstance.class.isAssignableFrom(advisedSupport.getTargetClass())) {
return true;
}
Expand All @@ -51,6 +52,6 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA

@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* org.springframework.aop.framework.DefaultAopProxyFactory#hasNoUserSuppliedProxyInterfaces} method by using {@link
* org.skywalking.apm.plugin.spring.patch.CreateAopProxyInterceptor} class.
*
* 参见 :https://github.com/apache/incubator-skywalking/issues/581
*
* @author zhangxin
*/
public class AopProxyFactoryInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
Expand Down

0 comments on commit 9ee7c47

Please sign in to comment.