From 44e966526219bf88f8f4176b7cc9061e1adf252b Mon Sep 17 00:00:00 2001 From: ascrutae Date: Fri, 26 Jan 2018 18:55:19 +0800 Subject: [PATCH] [Agent] modify the method matcher of spring bean --- .../spring-annotation-plugin/README.md | 18 ------------------ .../AbstractSpringBeanInstrumentation.java | 5 ++++- 2 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/README.md diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/README.md b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/README.md deleted file mode 100644 index 6cf0c4c1f..000000000 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Spring Annotation Plugin (Optional) - -Date: 2018/01/24 - -## Purpose -Because of multiple project are used - -Spring annotation plugin is an Optional plugin, the plugin -and if you want to active the plugin, you should move the plugin jar to the plugins folder. -The plugin will intercept all public method in the classs annotation with the following annotation. -1. `@Bean` -2. `@Service` -3. `@Componet` -4. `@Repository` - -## Purpose - - diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/annotations/AbstractSpringBeanInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/annotations/AbstractSpringBeanInstrumentation.java index 1bee08a51..fd769f8fd 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/annotations/AbstractSpringBeanInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/annotations/AbstractSpringBeanInstrumentation.java @@ -24,7 +24,10 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy; import static net.bytebuddy.matcher.ElementMatchers.isPublic; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.not; public abstract class AbstractSpringBeanInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.spring.annotations.SpringAnnotationInterceptor"; @@ -37,7 +40,7 @@ public abstract class AbstractSpringBeanInstrumentation extends ClassInstanceMet return new InstanceMethodsInterceptPoint[] { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return isPublic(); + return isPublic().and(not(isDeclaredBy(Object.class)).and(not(named("getSkyWalkingDynamicField"))).and(not(named("setSkyWalkingDynamicField")))); } @Override public String getMethodsInterceptor() {