Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
10346925
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10346925
编写于
7月 12, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support plugin match by annotation, can’t by interface yet. #281
上级
64435c3e
变更
40
隐藏空白更改
内联
并排
Showing
40 changed file
with
271 addition
and
197 deletion
+271
-197
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
...walking/apm/agent/core/conf/SnifferConfigInitializer.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
...walking/apm/agent/core/context/AbstractTracerContext.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
...org/skywalking/apm/agent/core/context/ContextManager.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java
...g/skywalking/apm/agent/core/dictionary/PossibleFound.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
...m/agent/core/plugin/AbstractClassEnhancePluginDefine.java
+3
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java
...va/org/skywalking/apm/agent/core/plugin/PluginFinder.java
+59
-16
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java
...rg/skywalking/apm/agent/core/plugin/TracingBootstrap.java
+0
-74
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/bytebuddy/judge/AbstractJunction.java
...m/agent/core/plugin/bytebuddy/judge/AbstractJunction.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/AnnotationMatch.java
...ywalking/apm/agent/core/plugin/match/AnnotationMatch.java
+40
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/ClassMatch.java
...rg/skywalking/apm/agent/core/plugin/match/ClassMatch.java
+7
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/HierarchyMatch.java
...kywalking/apm/agent/core/plugin/match/HierarchyMatch.java
+22
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/NameMatch.java
...org/skywalking/apm/agent/core/plugin/match/NameMatch.java
+20
-0
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
...c/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
+5
-22
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java
...ywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java
+0
-24
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java
...org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java
...eign/http/v9/define/DefaultHttpClientInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java
...tpClient/v4/define/AbstractHttpClientInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java
...ient/v4/define/DefaultRequestDirectorInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java
...lugin/httpClient/v4/define/HttpClientInstrumentation.java
+1
-1
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java
...tpClient/v4/define/InternalHttpClientInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java
...ttpClient/v4/define/MinimalHttpClientInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java
.../skywalking/apm/plugin/jdbc/define/H2Instrumentation.java
+6
-2
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java
...ywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java
+6
-2
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java
...walking/apm/plugin/jdbc/define/OracleInstrumentation.java
+6
-2
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java
...m/plugin/jedis/v2/define/JedisClusterInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java
...king/apm/plugin/jedis/v2/define/JedisInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java
.../apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java
...apm/plugin/motan/define/MotanConsumerInstrumentation.java
+6
-4
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java
...apm/plugin/motan/define/MotanProviderInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
.../apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java
...ng/apm/plugin/resin/v3/define/ResinV3Instrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java
...ng/apm/plugin/resin/v4/define/ResinV4Instrumentation.java
+4
-2
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
...ng/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
+4
-2
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
...ion/log/log4j/v1/x/TraceIdPatternConverterActivation.java
+4
-2
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
...vation/log/log4j/v2/x/Log4j2OutputAppenderActivation.java
+4
-2
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
...n/log/logback/v1/x/LogbackPatternConverterActivation.java
+4
-2
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java
...racing/continuation/SkywalkingContinuationActivation.java
+4
-2
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java
...activation/opentracing/span/SkywalkingSpanActivation.java
+4
-2
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java
...vation/opentracing/tracer/SkywalkingTracerActivation.java
+4
-2
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java
.../apm/toolkit/activation/trace/TraceContextActivation.java
+4
-2
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
浏览文件 @
10346925
...
...
@@ -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
();
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
浏览文件 @
10346925
...
...
@@ -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.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
10346925
...
...
@@ -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
();
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java
浏览文件 @
10346925
package
org.skywalking.apm.agent.core.dictionary
;
/**
* The <code>PossibleFound</code> represents a value, which may
exist
or not.
* The <code>PossibleFound</code> represents a value, which may
needEnhance
or not.
*
* @author wusheng
*/
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginFinder.java
浏览文件 @
10346925
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 <code>PluginFinder</code> 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
<
String
,
LinkedList
<
AbstractClassEnhancePluginDefine
>>
pluginDefineMap
=
new
HashMap
<
String
,
LinkedList
<
AbstractClassEnhancePluginDefine
>>();
private
final
Map
<
String
,
AbstractClassEnhancePluginDefine
>
nameMatchDefine
=
new
HashMap
<
String
,
AbstractClassEnhancePluginDefine
>();
private
final
List
<
AbstractClassEnhancePluginDefine
>
signatureMatchDefine
=
new
LinkedList
<
AbstractClassEnhancePluginDefine
>();
public
PluginFinder
(
List
<
AbstractClassEnhancePluginDefine
>
plugins
)
{
for
(
AbstractClassEnhancePluginDefine
plugin
:
plugins
)
{
String
enhanceClassName
=
plugin
.
enhanceClassName
();
ClassMatch
match
=
plugin
.
enhanceClass
();
if
(
enhanceClassName
==
null
)
{
if
(
match
==
null
)
{
continue
;
}
LinkedList
<
AbstractClassEnhancePluginDefine
>
pluginDefinesWithSameTarget
=
pluginDefineMap
.
get
(
enhanceClassName
);
if
(
pluginDefinesWithSameTarget
==
null
)
{
pluginDefinesWithSameTarget
=
new
LinkedList
<
AbstractClassEnhancePluginDefine
>();
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
<
AbstractClassEnhancePluginDefine
>
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
);
}
for
(
AbstractClassEnhancePluginDefine
pluginDefine
:
signatureMatchDefine
)
{
ClassMatch
classMatch
=
pluginDefine
.
enhanceClass
();
if
(
classMatch
instanceof
AnnotationMatch
)
{
AnnotationMatch
annotationMatch
=
(
AnnotationMatch
)
classMatch
;
List
<
String
>
annotationList
=
Arrays
.
asList
(
annotationMatch
.
getAnnotations
());
AnnotationList
declaredAnnotations
=
typeDescription
.
getDeclaredAnnotations
();
for
(
AnnotationDescription
annotation
:
declaredAnnotations
)
{
annotationList
.
remove
(
annotation
.
getAnnotationType
().
getActualName
());
}
if
(
annotationList
.
isEmpty
())
{
return
pluginDefine
;
}
}
}
throw
new
PluginException
(
"Can not find plugin:"
+
enhanceClassName
)
;
return
null
;
}
public
boolean
exist
(
String
enhanceClassName
)
{
return
pluginDefineMap
.
containsKey
(
enhanceClassName
);
public
ElementMatcher
<?
super
TypeDescription
>
buildMatch
()
{
ElementMatcher
.
Junction
judge
=
new
AbstractJunction
<
NamedElement
>()
{
@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
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/TracingBootstrap.java
已删除
100644 → 0
浏览文件 @
64435c3e
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
<
AbstractClassEnhancePluginDefine
>
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
});
}
}
apm-sniffer/apm-agent
/src/main/java/org/skywalking/apm/agent/junction
/AbstractJunction.java
→
apm-sniffer/apm-agent
-core/src/main/java/org/skywalking/apm/agent/core/plugin/bytebuddy/judge
/AbstractJunction.java
浏览文件 @
10346925
package
org.skywalking.apm.agent.
junction
;
package
org.skywalking.apm.agent.
core.plugin.bytebuddy.judge
;
import
net.bytebuddy.matcher.ElementMatcher
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/AnnotationMatch.java
0 → 100644
浏览文件 @
10346925
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
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/ClassMatch.java
0 → 100644
浏览文件 @
10346925
package
org.skywalking.apm.agent.core.plugin.match
;
/**
* @author wusheng
*/
public
abstract
class
ClassMatch
{
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/HierarchyMatch.java
0 → 100644
浏览文件 @
10346925
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
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/match/NameMatch.java
0 → 100644
浏览文件 @
10346925
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
);
}
}
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
浏览文件 @
10346925
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
<
AbstractClassEnhancePluginDefine
>
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 <T>
* @return class matcher.
*/
private
static
<
T
extends
NamedElement
>
ElementMatcher
.
Junction
<
T
>
enhanceClassMatcher
(
PluginFinder
pluginFinder
)
{
return
new
SkyWalkingEnhanceMatcher
<
T
>(
pluginFinder
);
}
}
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/junction/SkyWalkingEnhanceMatcher.java
已删除
100644 → 0
浏览文件 @
64435c3e
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.
* <p>
* Created by wusheng on 16/7/31.
*/
public
class
SkyWalkingEnhanceMatcher
<
T
extends
NamedElement
>
extends
AbstractJunction
<
T
>
{
private
final
PluginFinder
pluginFinder
;
public
SkyWalkingEnhanceMatcher
(
PluginFinder
pluginFinder
)
{
this
.
pluginFinder
=
pluginFinder
;
}
@Override
public
boolean
matches
(
T
target
)
{
return
pluginFinder
.
exist
(
target
.
getActualName
());
}
}
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/skywalking/apm/plugin/dubbo/DubboInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/skywalking/apm/plugin/feign/http/v9/define/DefaultHttpClientInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
()
{
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/AbstractHttpClientInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
)
;
}
/**
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/DefaultRequestDirectorInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/HttpClientInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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#enhanceClass
Name
()}
* {@link HttpClientInstrumentation} present that skywalking intercepts {@link HttpClientInstrumentation#enhanceClass()}
* by using {@link HttpClientExecuteInterceptor}
*
* @author zhangxin
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/InternalHttpClientInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/apm/plugin/httpClient/v4/define/MinimalHttpClientInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java
浏览文件 @
10346925
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
)
;
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java
浏览文件 @
10346925
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"
)
;
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java
浏览文件 @
10346925
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 <code>oracle.jdbc.OracleDriver
* </code>.
...
...
@@ -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"
)
;
}
}
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisClusterInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jedis/v2/define/JedisInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/define/MongoDBInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
)
;
}
}
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanConsumerInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/main/java/org/skywalking/apm/plugin/motan/define/MotanProviderInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
()
{
...
...
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v3/define/ResinV3Instrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/main/java/org/skywalking/apm/plugin/resin/v4/define/ResinV4Instrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
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
浏览文件 @
10346925
...
...
@@ -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"
)
;
}
/**
...
...
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
浏览文件 @
10346925
...
...
@@ -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"
)
;
}
/**
...
...
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
浏览文件 @
10346925
...
...
@@ -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"
)
;
}
/**
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/continuation/SkywalkingContinuationActivation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/span/SkywalkingSpanActivation.java
浏览文件 @
10346925
...
...
@@ -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
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-opentracing-activation/src/main/java/org/skywalking/apm/toolkit/activation/opentracing/tracer/SkywalkingTracerActivation.java
浏览文件 @
10346925
...
...
@@ -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
()
{
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-context-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextActivation.java
浏览文件 @
10346925
...
...
@@ -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"
)
;
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录