[Agent] modify the method matcher of spring bean

This commit is contained in:
ascrutae 2018-01-26 18:55:19 +08:00
parent f377c3350e
commit 44e9665262
2 changed files with 4 additions and 19 deletions

View File

@ -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

View File

@ -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<MethodDescription> getMethodsMatcher() {
return isPublic();
return isPublic().and(not(isDeclaredBy(Object.class)).and(not(named("getSkyWalkingDynamicField"))).and(not(named("setSkyWalkingDynamicField"))));
}
@Override public String getMethodsInterceptor() {