diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java index 78043f98c..2a619b1a5 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java @@ -83,7 +83,7 @@ public class SnifferConfigInitializer { /** * Load the config file by the path, which is provided by system property, usually with a "-DconfigPath=" arg. * - * @return the config file {@link InputStream}, or null if not exist. + * @return the config file {@link InputStream}, or null if not needEnhance. */ private static InputStream loadConfigBySystemProperty() { String configPath = System.getProperty("configPath"); @@ -107,7 +107,7 @@ public class SnifferConfigInitializer { /** * Load the config file, where the agent jar is. * - * @return the config file {@link InputStream}, or null if not exist. + * @return the config file {@link InputStream}, or null if not needEnhance. */ private static InputStream loadConfigFromAgentFolder() { String agentBasePath = initAgentBasePath(); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java index 8ac49fbb8..3b9d569d1 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java @@ -49,7 +49,7 @@ public interface AbstractTracerContext { void continued(ContextSnapshot snapshot); /** - * Get the global trace id, if exist. + * Get the global trace id, if needEnhance. * How to build, depends on the implementation. * * @return the string represents the id. diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java index 040f703a1..a34458464 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java @@ -69,7 +69,7 @@ public class ContextManager implements TracingContextListener, BootService, Igno } /** - * @return the first global trace id if exist. Otherwise, "N/A". + * @return the first global trace id if needEnhance. Otherwise, "N/A". */ public static String getGlobalTraceId() { AbstractTracerContext segment = CONTEXT.get(); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java index 89e924ec2..cc865a9a1 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java @@ -1,7 +1,7 @@ package org.skywalking.apm.agent.core.dictionary; /** - * The PossibleFound represents a value, which may exist or not. + * The PossibleFound represents a value, which may needEnhance or not. * * @author wusheng */ diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java index 008d49e8b..87b573d2b 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java @@ -2,6 +2,7 @@ package org.skywalking.apm.agent.core.plugin; import net.bytebuddy.dynamic.DynamicType; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.util.StringUtil; import org.skywalking.apm.logging.ILog; import org.skywalking.apm.logging.LogManager; @@ -65,9 +66,9 @@ public abstract class AbstractClassEnhancePluginDefine { /** * Define the classname of target class. * - * @return class full name. + * @return {@link ClassMatch} */ - protected abstract String enhanceClassName(); + protected abstract ClassMatch enhanceClass(); /** * Witness classname list. Why need witness classname? Let's see like this: A library existed two released versions diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java index 45ce1d5b5..baeffb06a 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java @@ -1,46 +1,89 @@ package org.skywalking.apm.agent.core.plugin; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import net.bytebuddy.description.NamedElement; +import net.bytebuddy.description.annotation.AnnotationDescription; +import net.bytebuddy.description.annotation.AnnotationList; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.skywalking.apm.agent.core.plugin.bytebuddy.judge.AbstractJunction; +import org.skywalking.apm.agent.core.plugin.match.AnnotationMatch; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.isInterface; +import static net.bytebuddy.matcher.ElementMatchers.not; /** * The PluginFinder represents a finder , which assist to find the one - * from the given {@link AbstractClassEnhancePluginDefine} list, by name match. + * from the given {@link AbstractClassEnhancePluginDefine} list. * * @author wusheng */ public class PluginFinder { - private final Map> pluginDefineMap = new HashMap>(); + private final Map nameMatchDefine = new HashMap(); + private final List signatureMatchDefine = new LinkedList(); public PluginFinder(List plugins) { for (AbstractClassEnhancePluginDefine plugin : plugins) { - String enhanceClassName = plugin.enhanceClassName(); + ClassMatch match = plugin.enhanceClass(); - if (enhanceClassName == null) { + if (match == null) { continue; } - LinkedList pluginDefinesWithSameTarget = pluginDefineMap.get(enhanceClassName); - if (pluginDefinesWithSameTarget == null) { - pluginDefinesWithSameTarget = new LinkedList(); - pluginDefineMap.put(enhanceClassName, pluginDefinesWithSameTarget); + if (match instanceof NameMatch) { + NameMatch nameMatch = (NameMatch)match; + nameMatchDefine.put(nameMatch.getClassName(), plugin); + } else { + signatureMatchDefine.add(plugin); } - - pluginDefinesWithSameTarget.add(plugin); } } - public List find(String enhanceClassName) { - if (pluginDefineMap.containsKey(enhanceClassName)) { - return pluginDefineMap.get(enhanceClassName); + public AbstractClassEnhancePluginDefine find(TypeDescription typeDescription, + ClassLoader classLoader) { + String typeName = typeDescription.getTypeName(); + if (nameMatchDefine.containsKey(typeName)) { + return nameMatchDefine.get(typeName); } - throw new PluginException("Can not find plugin:" + enhanceClassName); + for (AbstractClassEnhancePluginDefine pluginDefine : signatureMatchDefine) { + ClassMatch classMatch = pluginDefine.enhanceClass(); + if (classMatch instanceof AnnotationMatch) { + AnnotationMatch annotationMatch = (AnnotationMatch)classMatch; + List annotationList = Arrays.asList(annotationMatch.getAnnotations()); + AnnotationList declaredAnnotations = typeDescription.getDeclaredAnnotations(); + for (AnnotationDescription annotation : declaredAnnotations) { + annotationList.remove(annotation.getAnnotationType().getActualName()); + } + if (annotationList.isEmpty()) { + return pluginDefine; + } + } + } + + return null; } - public boolean exist(String enhanceClassName) { - return pluginDefineMap.containsKey(enhanceClassName); + public ElementMatcher buildMatch() { + ElementMatcher.Junction judge = new AbstractJunction() { + @Override + public boolean matches(NamedElement target) { + return nameMatchDefine.containsKey(target.getActualName()); + } + }; + judge = judge.and(not(isInterface())); + for (AbstractClassEnhancePluginDefine define : signatureMatchDefine) { + ClassMatch match = define.enhanceClass(); + if (match instanceof AnnotationMatch) { + judge = judge.or(((AnnotationMatch)match).buildJunction()); + } + } + return judge; } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java deleted file mode 100644 index 00e004a4a..000000000 --- a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.skywalking.apm.agent.core.plugin; - -import net.bytebuddy.ByteBuddy; -import net.bytebuddy.dynamic.ClassFileLocator; -import net.bytebuddy.dynamic.DynamicType; -import net.bytebuddy.dynamic.TypeResolutionStrategy; -import net.bytebuddy.dynamic.loading.ClassLoadingStrategy; -import net.bytebuddy.pool.TypePool; -import org.skywalking.apm.logging.ILog; -import org.skywalking.apm.logging.LogManager; - -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.List; - -/** - * A test entrance for enhancing class. - * This should be used only in bytecode-manipulate test. - * And make sure, all classes which need to be enhanced, must not be loaded. - * - * @author wusheng - */ -public class TracingBootstrap { - private static final ILog logger = LogManager.getLogger(TracingBootstrap.class); - - private TracingBootstrap() { - } - - /** - * Main entrance for testing. - * - * @param args includes target classname ( which exists "public static void main(String[] args)" ) and arguments - * list. - * @throws PluginException - * @throws ClassNotFoundException - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - public static void main(String[] args) - throws PluginException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, - IllegalAccessException { - if (args.length == 0) { - throw new RuntimeException("bootstrap failure. need args[0] to be main class."); - } - - List plugins = null; - - try { - PluginBootstrap bootstrap = new PluginBootstrap(); - plugins = bootstrap.loadPlugins(); - } catch (Throwable t) { - logger.error("PluginBootstrap start failure.", t); - } - - for (AbstractClassEnhancePluginDefine plugin : plugins) { - String enhanceClassName = plugin.enhanceClassName(); - TypePool.Resolution resolution = TypePool.Default.ofClassPath().describe(enhanceClassName); - if (!resolution.isResolved()) { - logger.error("Failed to resolve the class " + enhanceClassName, null); - continue; - } - DynamicType.Builder newClassBuilder = - new ByteBuddy().rebase(resolution.resolve(), ClassFileLocator.ForClassLoader.ofClassPath()); - newClassBuilder = ((AbstractClassEnhancePluginDefine)plugin).define(enhanceClassName, newClassBuilder, TracingBootstrap.class.getClassLoader()); - newClassBuilder.make(new TypeResolutionStrategy.Active()).load(ClassLoader.getSystemClassLoader(), ClassLoadingStrategy.Default.INJECTION) - .getLoaded(); - } - - String[] newArgs = Arrays.copyOfRange(args, 1, args.length); - - Class.forName(args[0]).getMethod("main", String[].class).invoke(null, new Object[] {newArgs}); - } -} diff --git a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/AbstractJunction.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/bytebuddy/judge/AbstractJunction.java similarity index 88% rename from apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/AbstractJunction.java rename to apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/bytebuddy/judge/AbstractJunction.java index 207dada85..8fbacd219 100644 --- a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/AbstractJunction.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/bytebuddy/judge/AbstractJunction.java @@ -1,4 +1,4 @@ -package org.skywalking.apm.agent.junction; +package org.skywalking.apm.agent.core.plugin.bytebuddy.judge; import net.bytebuddy.matcher.ElementMatcher; diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/AnnotationMatch.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/AnnotationMatch.java new file mode 100644 index 000000000..ecdaf4a94 --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/AnnotationMatch.java @@ -0,0 +1,40 @@ +package org.skywalking.apm.agent.core.plugin.match; + +import net.bytebuddy.matcher.ElementMatcher; + +import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith; +import static net.bytebuddy.matcher.ElementMatchers.isInterface; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.not; + +/** + * @author wusheng + */ +public class AnnotationMatch extends ClassMatch { + private String[] annotations; + + public AnnotationMatch(String[] annotations) { + this.annotations = annotations; + } + + public ElementMatcher.Junction buildJunction() { + ElementMatcher.Junction junction = null; + for (String annotation : annotations) { + if (junction == null) { + junction = buildEachAnnotation(annotation); + } else { + junction = junction.and(buildEachAnnotation(annotation)); + } + } + junction = junction.and(not(isInterface())); + return junction; + } + + private ElementMatcher.Junction buildEachAnnotation(String annotationName) { + return isAnnotatedWith(named(annotationName)); + } + + public String[] getAnnotations() { + return annotations; + } +} diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/ClassMatch.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/ClassMatch.java new file mode 100644 index 000000000..b1fe0140f --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/ClassMatch.java @@ -0,0 +1,7 @@ +package org.skywalking.apm.agent.core.plugin.match; + +/** + * @author wusheng + */ +public abstract class ClassMatch { +} diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/HierarchyMatch.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/HierarchyMatch.java new file mode 100644 index 000000000..b9a609c79 --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/HierarchyMatch.java @@ -0,0 +1,22 @@ +package org.skywalking.apm.agent.core.plugin.match; + +import net.bytebuddy.matcher.ElementMatcher; + +/** + * @author wusheng + */ +public class HierarchyMatch extends ClassMatch { + private String[] parentTypes; + + public HierarchyMatch(String[] parentTypes) { + this.parentTypes = parentTypes; + } + + public ElementMatcher.Junction buildJunction() { + return null; + } + + private ElementMatcher.Junction buildEachParent(String parentType) { + return null; + } +} diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/NameMatch.java b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/NameMatch.java new file mode 100644 index 000000000..1ab9c454c --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/NameMatch.java @@ -0,0 +1,20 @@ +package org.skywalking.apm.agent.core.plugin.match; + +/** + * @author wusheng + */ +public class NameMatch extends ClassMatch { + private String className; + + public NameMatch(String className) { + this.className = className; + } + + public String getClassName() { + return className; + } + + public static NameMatch byName(String className) { + return new NameMatch(className); + } +} diff --git a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java b/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java index e51cf9f8e..ea411dd9a 100644 --- a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java +++ b/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java @@ -1,12 +1,9 @@ package org.skywalking.apm.agent; import java.lang.instrument.Instrumentation; -import java.util.List; import net.bytebuddy.agent.builder.AgentBuilder; -import net.bytebuddy.description.NamedElement; import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.dynamic.DynamicType; -import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.utility.JavaModule; import org.skywalking.apm.agent.core.boot.ServiceManager; import org.skywalking.apm.agent.core.conf.SnifferConfigInitializer; @@ -15,13 +12,9 @@ import org.skywalking.apm.agent.core.plugin.AbstractClassEnhancePluginDefine; import org.skywalking.apm.agent.core.plugin.PluginBootstrap; import org.skywalking.apm.agent.core.plugin.PluginException; import org.skywalking.apm.agent.core.plugin.PluginFinder; -import org.skywalking.apm.agent.junction.SkyWalkingEnhanceMatcher; import org.skywalking.apm.logging.ILog; import org.skywalking.apm.logging.LogManager; -import static net.bytebuddy.matcher.ElementMatchers.isInterface; -import static net.bytebuddy.matcher.ElementMatchers.not; - /** * The main entrance of sky-waking agent, * based on javaagent mechanism. @@ -51,19 +44,20 @@ public class SkyWalkingAgent { ServiceManager.INSTANCE.boot(); - new AgentBuilder.Default().type(enhanceClassMatcher(pluginFinder).and(not(isInterface()))).transform(new AgentBuilder.Transformer() { + new AgentBuilder.Default().type(pluginFinder.buildMatch()).transform(new AgentBuilder.Transformer() { @Override public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule module) { - List pluginDefines = pluginFinder.find(typeDescription.getTypeName()); - for (AbstractClassEnhancePluginDefine pluginDefine : pluginDefines) { + AbstractClassEnhancePluginDefine pluginDefine = pluginFinder.find(typeDescription, classLoader); + if (pluginDefine != null) { DynamicType.Builder newBuilder = pluginDefine.define(typeDescription.getTypeName(), builder, classLoader); if (newBuilder != null) { + logger.debug("Finish the prepare stage for {}.", typeDescription.getName()); return newBuilder; } } - logger.warn("Matched class {}, but enhancement fails.", typeDescription.getTypeName()); + logger.debug("Matched class {}, but ignore by finding mechanism.", typeDescription.getTypeName()); return builder; } }).with(new AgentBuilder.Listener() { @@ -96,15 +90,4 @@ public class SkyWalkingAgent { } }).installOn(instrumentation); } - - /** - * Get the enhance target classes matcher. - * - * @param pluginFinder - * @param - * @return class matcher. - */ - private static ElementMatcher.Junction enhanceClassMatcher(PluginFinder pluginFinder) { - return new SkyWalkingEnhanceMatcher(pluginFinder); - } } diff --git a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java b/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java deleted file mode 100644 index 5b1b211cc..000000000 --- a/apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.skywalking.apm.agent.junction; - -import net.bytebuddy.description.NamedElement; -import org.skywalking.apm.agent.core.plugin.PluginFinder; - -/** - * The matcher bases on byte-buddy {@link AbstractJunction} class. - * Judge the target class in transforming, should be enhanced or not. - *

- * Created by wusheng on 16/7/31. - */ -public class SkyWalkingEnhanceMatcher extends AbstractJunction { - - private final PluginFinder pluginFinder; - - public SkyWalkingEnhanceMatcher(PluginFinder pluginFinder) { - this.pluginFinder = pluginFinder; - } - - @Override - public boolean matches(T target) { - return pluginFinder.exist(target.getActualName()); - } -} diff --git a/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java b/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java index e6e1f4f44..89dcdcd42 100644 --- a/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java @@ -5,8 +5,10 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link DubboInstrumentation} presents that skywalking intercepts {@link com.alibaba.dubbo.monitor.support.MonitorFilter#invoke(com.alibaba.dubbo.rpc.Invoker, @@ -20,8 +22,8 @@ public class DubboInstrumentation extends ClassInstanceMethodsEnhancePluginDefin private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.dubbo.DubboInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java index 1dcf57459..1dc3bff3e 100644 --- a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java @@ -5,9 +5,11 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.feign.http.v9.DefaultHttpClientInterceptor; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link DefaultHttpClientInstrumentation} presents that skywalking intercepts {@link @@ -29,8 +31,8 @@ public class DefaultHttpClientInstrumentation extends ClassInstanceMethodsEnhanc */ private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.feign.http.v9.DefaultHttpClientInterceptor"; - @Override protected String enhanceClassName() { - return ENHANCE_CLASS; + @Override protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java index 93f446675..a1dcbc484 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java @@ -6,8 +6,10 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.protocol.HttpContext; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link AbstractHttpClientInstrumentation} presents that skywalking intercepts @@ -21,8 +23,8 @@ public class AbstractHttpClientInstrumentation extends HttpClientInstrumentation private static final String ENHANCE_CLASS = "org.apache.http.impl.discovery.AbstractHttpClient"; @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } /** diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java index 3665c618a..969193852 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java @@ -3,8 +3,10 @@ package org.skywalking.apm.plugin.httpClient.v4.define; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; public class DefaultRequestDirectorInstrumentation extends HttpClientInstrumentation { @@ -19,8 +21,8 @@ public class DefaultRequestDirectorInstrumentation extends HttpClientInstrumenta * since 4.3, this class is Deprecated. */ @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java index 3317fe869..09cb9f4f1 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java @@ -5,7 +5,7 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet import org.skywalking.apm.plugin.httpClient.v4.HttpClientExecuteInterceptor; /** - * {@link HttpClientInstrumentation} present that skywalking intercepts {@link HttpClientInstrumentation#enhanceClassName()} + * {@link HttpClientInstrumentation} present that skywalking intercepts {@link HttpClientInstrumentation#enhanceClass()} * by using {@link HttpClientExecuteInterceptor} * * @author zhangxin diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java index 9c7919fb8..e873cfd52 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java @@ -3,8 +3,10 @@ package org.skywalking.apm.plugin.httpClient.v4.define; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link AbstractHttpClientInstrumentation} presents that skywalking intercepts {@link @@ -18,8 +20,8 @@ public class InternalHttpClientInstrumentation extends HttpClientInstrumentation private static final String ENHANCE_CLASS = "org.apache.http.impl.discovery.InternalHttpClient"; @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java index e9f2ca753..714e4f2f7 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java @@ -6,8 +6,10 @@ import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.protocol.HttpContext; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link AbstractHttpClientInstrumentation} presents that skywalking @@ -21,8 +23,8 @@ public class MinimalHttpClientInstrumentation extends HttpClientInstrumentation private static final String ENHANCE_CLASS = "org.apache.http.impl.discovery.MinimalHttpClient"; @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java index c7566cf47..8bc9e6033 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java @@ -1,5 +1,9 @@ package org.skywalking.apm.plugin.jdbc.define; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + /** * {@link H2Instrumentation} presents that skywalking intercepts {@link org.h2.Driver}. * @@ -10,7 +14,7 @@ public class H2Instrumentation extends AbstractDatabaseInstrumentation { private static final String CLASS_OF_INTERCEPT_H2_DRIVER = "org.h2.Driver"; @Override - protected String enhanceClassName() { - return CLASS_OF_INTERCEPT_H2_DRIVER; + protected ClassMatch enhanceClass() { + return byName(CLASS_OF_INTERCEPT_H2_DRIVER); } } diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java index 9fb9b386d..27ed5e4e5 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java @@ -1,5 +1,9 @@ package org.skywalking.apm.plugin.jdbc.define; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + /** * {@link MysqlInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}. * @@ -7,7 +11,7 @@ package org.skywalking.apm.plugin.jdbc.define; */ public class MysqlInstrumentation extends AbstractDatabaseInstrumentation { @Override - protected String enhanceClassName() { - return "com.mysql.jdbc.Driver"; + protected ClassMatch enhanceClass() { + return byName("com.mysql.jdbc.Driver"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java index 8929045a8..7075d8243 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java @@ -1,5 +1,9 @@ package org.skywalking.apm.plugin.jdbc.define; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + /** * {@link OracleInstrumentation} presents that skywalking intercepts the class oracle.jdbc.OracleDriver * . @@ -8,7 +12,7 @@ package org.skywalking.apm.plugin.jdbc.define; */ public class OracleInstrumentation extends AbstractDatabaseInstrumentation { @Override - protected String enhanceClassName() { - return "oracle.jdbc.driver.OracleDriver"; + protected ClassMatch enhanceClass() { + return byName("oracle.jdbc.driver.OracleDriver"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java index 5a9ebd9f3..5e928d02d 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java @@ -6,6 +6,7 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor; import org.skywalking.apm.plugin.jedis.v2.JedisClusterConstructorWithListHostAndPortArgInterceptor; import org.skywalking.apm.plugin.jedis.v2.JedisMethodInterceptor; @@ -13,6 +14,7 @@ import org.skywalking.apm.plugin.jedis.v2.RedisMethodMatch; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link JedisClusterInstrumentation} presents that skywalking intercepts all constructors and methods of {@link @@ -32,8 +34,8 @@ public class JedisClusterInstrumentation extends ClassInstanceMethodsEnhancePlug private static final String CONSTRUCTOR_WITH_HOSTANDPORT_ARG_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jedis.v2.JedisClusterConstructorWithHostAndPortArgInterceptor"; @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java index 93e14fc4d..9a9e24cb5 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java @@ -6,6 +6,7 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.jedis.v2.JedisConstructorWithShardInfoArgInterceptor; import org.skywalking.apm.plugin.jedis.v2.JedisConstructorWithUriArgInterceptor; import org.skywalking.apm.plugin.jedis.v2.JedisMethodInterceptor; @@ -13,6 +14,7 @@ import org.skywalking.apm.plugin.jedis.v2.RedisMethodMatch; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link JedisInstrumentation} presents that skywalking intercept all constructors and methods of {@link @@ -34,8 +36,8 @@ public class JedisInstrumentation extends ClassInstanceMethodsEnhancePluginDefin private static final String JEDIS_METHOD_INTERCET_CLASS = "org.skywalking.apm.plugin.jedis.v2.JedisMethodInterceptor"; @Override - public String enhanceClassName() { - return ENHANCE_CLASS; + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java index 5dba13495..9ce9154cd 100644 --- a/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java @@ -6,9 +6,11 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { @@ -56,8 +58,8 @@ public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDef } @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } } diff --git a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java index 4eb8b5334..8b73b6873 100644 --- a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java @@ -5,13 +5,15 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.motan.MotanProviderInterceptor; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** - * {@link MotanConsumerInstrumentation} presents that skywalking intercept - * {@link com.weibo.api.motan.cluster.support.ClusterSpi#call(com.weibo.api.motan.rpc.Request)} by using {@link MotanProviderInterceptor}. + * {@link MotanConsumerInstrumentation} presents that skywalking intercept {@link com.weibo.api.motan.cluster.support.ClusterSpi#call(com.weibo.api.motan.rpc.Request)} + * by using {@link MotanProviderInterceptor}. * * @author zhangxin */ @@ -22,8 +24,8 @@ public class MotanConsumerInstrumentation extends ClassInstanceMethodsEnhancePlu private static final String INVOKE_INTERCEPT_CLASS = "org.skywalking.apm.plugin.motan.MotanProviderInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java index 1b54709a2..756684ff8 100644 --- a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java @@ -6,10 +6,12 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.motan.MotanConsumerInterceptor; import static net.bytebuddy.matcher.ElementMatchers.any; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link MotanProviderInstrumentation} presents that skywalking will use @@ -35,8 +37,8 @@ public class MotanProviderInstrumentation extends ClassInstanceMethodsEnhancePlu private static final String PROVIDER_INVOKE_INTERCEPT_CLASS = "org.skywalking.apm.plugin.motan.MotanConsumerInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java index c7c14bb5e..0ce9f4182 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java @@ -7,10 +7,12 @@ import okhttp3.Request; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.okhttp.v3.RealCallInterceptor; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link RealCallInstrumentation} presents that skywalking intercepts {@link okhttp3.RealCall#RealCall(OkHttpClient, @@ -30,8 +32,8 @@ public class RealCallInstrumentation extends ClassInstanceMethodsEnhancePluginDe */ private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.okhttp.v3.RealCallInterceptor"; - @Override protected String enhanceClassName() { - return ENHANCE_CLASS; + @Override protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { diff --git a/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java b/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java index cc5a2ff84..59cd95fb2 100644 --- a/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java @@ -5,9 +5,11 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.resin.v3.ResinV3Interceptor; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link ResinV3Instrumentation} presents that skywalking intercepts {@link com.caucho.server.dispatch.ServletInvocation#service(javax.servlet.ServletRequest, @@ -49,8 +51,8 @@ public class ResinV3Instrumentation extends ClassInstanceMethodsEnhancePluginDef } @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java b/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java index e54559cc7..ac6fd8e3a 100644 --- a/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java @@ -5,9 +5,11 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.resin.v4.ResinV4Interceptor; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link ResinV4Instrumentation} presents that skywalking intercepts {@link com.caucho.server.dispatch.ServletInvocation#service(javax.servlet.ServletRequest, @@ -48,8 +50,8 @@ public class ResinV4Instrumentation extends ClassInstanceMethodsEnhancePluginDef } @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java index 419c579fc..971aa5126 100644 --- a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java @@ -7,9 +7,11 @@ import org.apache.catalina.connector.Response; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.skywalking.apm.plugin.tomcat78x.TomcatInterceptor; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link TomcatInstrumentation} presents that skywalking using class {@link TomcatInterceptor} to @@ -30,8 +32,8 @@ public class TomcatInstrumentation extends ClassInstanceMethodsEnhancePluginDefi private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.tomcat78x.TomcatInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java index 44ac68d9b..f9252dd6c 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v1/x/TraceIdPatternConverterActivation.java @@ -5,8 +5,10 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * Active the toolkit class "org.skywalking.apm.toolkit.log.log4j.v1.x.TraceIdPatternConverter". @@ -21,8 +23,8 @@ public class TraceIdPatternConverterActivation extends ClassInstanceMethodsEnhan * @return the target class, which needs active. */ @Override - protected String enhanceClassName() { - return "org.skywalking.apm.toolkit.log.log4j.v1.x.TraceIdPatternConverter"; + protected ClassMatch enhanceClass() { + return byName("org.skywalking.apm.toolkit.log.log4j.v1.x.TraceIdPatternConverter"); } /** diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-2.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-2.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java index 87a625252..0156de32f 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-2.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-log4j-2.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java @@ -4,8 +4,10 @@ import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * Active the toolkit class "org.skywalking.apm.toolkit.log.logback.v2.x.LogbackPatternConverter". @@ -20,8 +22,8 @@ public class Log4j2OutputAppenderActivation extends ClassStaticMethodsEnhancePlu * @return the target class, which needs active. */ @Override - protected String enhanceClassName() { - return "org.skywalking.apm.toolkit.log.log4j.v2.x.Log4j2OutputAppender"; + protected ClassMatch enhanceClass() { + return byName("org.skywalking.apm.toolkit.log.log4j.v2.x.Log4j2OutputAppender"); } /** diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java index fb43918f8..b9db5ce9d 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-logback-1.x-activation/src/main/java/org/skywalking/apm/toolkit/activation/log/logback/v1/x/LogbackPatternConverterActivation.java @@ -6,8 +6,10 @@ import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoin import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * Active the toolkit class "org.skywalking.apm.toolkit.log.logback.v1.x.LogbackPatternConverter". @@ -22,8 +24,8 @@ public class LogbackPatternConverterActivation extends ClassInstanceMethodsEnhan * @return the target class, which needs active. */ @Override - protected String enhanceClassName() { - return "org.skywalking.apm.toolkit.log.logback.v1.x.LogbackPatternConverter"; + protected ClassMatch enhanceClass() { + return byName("org.skywalking.apm.toolkit.log.logback.v1.x.LogbackPatternConverter"); } /** diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java index 45bf3a538..eb09593d5 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java @@ -5,9 +5,11 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.any; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link SkywalkingContinuationActivation} defines two interceptors to enhance the methods and constructor in class @@ -26,8 +28,8 @@ public class SkywalkingContinuationActivation extends ClassInstanceMethodsEnhanc private static final String ACTIVATE_METHOD_INTERCEPTOR = "org.skywalking.apm.toolkit.activation.opentracing.continuation.ActivateInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java index 6d1a5daeb..e68396cc8 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java @@ -6,10 +6,12 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link SkywalkingSpanActivation} defines five interceptors to enhance the methods and constructor in class @@ -48,8 +50,8 @@ public class SkywalkingSpanActivation extends ClassInstanceMethodsEnhancePluginD private static final String SET_OPERATION_NAME_INTERCEPTOR = "org.skywalking.apm.toolkit.activation.opentracing.span.SpanSetOperationNameInterceptor"; @Override - protected String enhanceClassName() { - return ENHANCE_CLASS; + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java index eb7dfb68a..5f3899728 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java @@ -5,8 +5,10 @@ import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * {@link SkywalkingTracerActivation} defines two interceptors to enhance the methods in @@ -24,8 +26,8 @@ public class SkywalkingTracerActivation extends ClassInstanceMethodsEnhancePlugi private static final String INJECT_INTERCEPTOR = "org.skywalking.apm.toolkit.activation.opentracing.tracer.SkywalkingTracerInjectInterceptor"; private static final String EXTRACT_INTERCEPTOR = "org.skywalking.apm.toolkit.activation.opentracing.tracer.SkywalkingTracerExtractInterceptor"; - @Override protected String enhanceClassName() { - return ENHANCE_CLASS; + @Override protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); } @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java index b4e355c5b..de543a902 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java @@ -4,8 +4,10 @@ import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.matcher.ElementMatcher; import org.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint; import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine; +import org.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** * Active the toolkit class "org.skywalking.apm.toolkit.trace.TraceContext". @@ -20,8 +22,8 @@ public class TraceContextActivation extends ClassStaticMethodsEnhancePluginDefin * @return the target class, which needs active. */ @Override - protected String enhanceClassName() { - return "org.skywalking.apm.toolkit.trace.TraceContext"; + protected ClassMatch enhanceClass() { + return byName("org.skywalking.apm.toolkit.trace.TraceContext"); } /**