Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
f50566dc
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
f50566dc
编写于
8月 12, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复bug
上级
fa2fdb4e
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
370 addition
and
50 deletion
+370
-50
samples/skywalking-auth/src/main/resources/sky-walking.auth
samples/skywalking-auth/src/main/resources/sky-walking.auth
+7
-0
skywalking-collector/skywalking-agent/pom.xml
skywalking-collector/skywalking-agent/pom.xml
+5
-0
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java
...pi/src/main/java/com/ai/cloud/skywalking/conf/Config.java
+12
-4
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
...ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
+1
-1
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
.../com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
+5
-0
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
...java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
+5
-0
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java
.../interceptor/enhance/ClassInstanceMethodsInterceptor.java
+1
-1
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java
...in/interceptor/enhance/ClassStaticMethodsInterceptor.java
+1
-1
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java
...ugin/interceptor/enhance/InstanceMethodInvokeContext.java
+2
-2
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java
...lking/plugin/interceptor/enhance/MethodInvokeContext.java
+8
-14
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodInvokeContext.java
...plugin/interceptor/enhance/StaticMethodInvokeContext.java
+17
-0
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
...n/interceptor/enhance/StaticMethodsAroundInterceptor.java
+2
-2
skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
...ava/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
+3
-2
skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth
...lector/skywalking-api/src/test/resources/sky-walking.auth
+6
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/pom.xml
...sdk-plugin/custom-local-method-interceptor-plugin/pom.xml
+2
-2
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodInterceptor.java
...ugin/custom/localmethod/CustomLocalMethodInterceptor.java
+28
-7
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalSpanType.java
...alking/plugin/custom/localmethod/CustomLocalSpanType.java
+2
-2
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/define/CustomLocalMethodPluginDefine.java
...tom/localmethod/define/CustomLocalMethodPluginDefine.java
+38
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/resources/skywalking-plugin.def
...terceptor-plugin/src/main/resources/skywalking-plugin.def
+1
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodPluginTest.java
...lugin/custom/localmethod/CustomLocalMethodPluginTest.java
+28
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestObject.java
...tor-plugin/src/test/java/test/com/ai/test/TestObject.java
+11
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestParam.java
...ptor-plugin/src/test/java/test/com/ai/test/TestParam.java
+7
-0
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/resources/sky-walking.auth
...od-interceptor-plugin/src/test/resources/sky-walking.auth
+54
-0
skywalking-collector/skywalking-sdk-plugin/pom.xml
skywalking-collector/skywalking-sdk-plugin/pom.xml
+1
-1
skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/resources/skywalking-plugin.def
...terceptor-plugin/src/main/resources/skywalking-plugin.def
+0
-1
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
...in/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
+7
-8
test/skywalking-agent-test/agent/sky-walking.auth
test/skywalking-agent-test/agent/sky-walking.auth
+54
-0
test/skywalking-agent-test/custom-local-method-test/pom.xml
test/skywalking-agent-test/custom-local-method-test/pom.xml
+15
-0
test/skywalking-agent-test/custom-local-method-test/src/main/java/com/ai/cloud/skywalking/agent/test/custom/localmethod/CustomLocalMethodPluginTest.java
.../test/custom/localmethod/CustomLocalMethodPluginTest.java
+19
-0
test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestObject.java
.../skywalking/agent/test/custom/localmethod/TestObject.java
+12
-0
test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestParam.java
...d/skywalking/agent/test/custom/localmethod/TestParam.java
+15
-0
test/skywalking-agent-test/pom.xml
test/skywalking-agent-test/pom.xml
+1
-2
未找到文件。
samples/skywalking-auth/src/main/resources/sky-walking.auth
浏览文件 @
f50566dc
...
...
@@ -45,3 +45,10 @@ buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
#自定义本地方法插件是否开启
plugin.customlocalmethodinterceptorplugin.is_enable=false
#自定义插件拦截的包前缀
plugin.customlocalmethodinterceptorplugin.package_prefix=
#自定义插件是否记录入参
plugin.customlocalmethodinterceptorplugin.record_param_enable=false
skywalking-collector/skywalking-agent/pom.xml
浏览文件 @
f50566dc
...
...
@@ -51,6 +51,11 @@
<artifactId>
tomcat-7.x-8.x-plugin
</artifactId>
<version>
1.0-Final
</version>
</dependency>
<dependency>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
custom-local-method-interceptor-plugin
</artifactId>
<version>
1.0-Final
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Config.java
浏览文件 @
f50566dc
...
...
@@ -19,13 +19,21 @@ public class Config {
public
static
String
AGENT_BASE_PATH
=
""
;
public
static
boolean
SELF_DEFINE_METHOD_INTERCEPTOR
=
false
;
}
public
static
String
SELF_DEFINE_METHOD_PACKAGE
=
""
;
public
static
boolean
RECORD_PARAM
=
false
;
}
public
static
class
Plugin
{
public
static
class
CustomLocalMethodInterceptorPlugin
{
public
static
boolean
IS_ENABLE
=
false
;
public
static
String
PACKAGE_PREFIX
=
""
;
public
static
boolean
RECORD_PARAM_ENABLE
=
false
;
}
}
public
static
class
BuriedPoint
{
// 是否打印埋点信息
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/invoke/monitor/BaseInvokeMonitor.java
浏览文件 @
f50566dc
...
...
@@ -39,7 +39,7 @@ public abstract class BaseInvokeMonitor {
ContextBuffer
.
save
(
RequestSpan
.
RequestSpanBuilder
.
newBuilder
(
CurrentThreadSpanStack
.
peek
()).
callType
(
id
.
getCallType
()).
viewPoint
(
id
.
getViewPoint
())
.
spanTypeDesc
(
id
.
getSpanTypeDesc
()).
processNo
(
BuriedPointMachineUtil
.
getProcessNo
())
.
address
(
BuriedPointMachineUtil
.
getHostDesc
()).
build
());
.
address
(
BuriedPointMachineUtil
.
getHostDesc
()).
parameters
(
id
.
getParameters
()).
build
());
// 并将当前的Context返回回去
return
new
ContextData
(
spanData
);
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginDefineCategory.java
浏览文件 @
f50566dc
...
...
@@ -16,6 +16,11 @@ public class PluginDefineCategory {
private
PluginDefineCategory
(
List
<
AbstractClassEnhancePluginDefine
>
plugins
)
{
for
(
AbstractClassEnhancePluginDefine
plugin
:
plugins
)
{
String
enhanceClassName
=
plugin
.
enhanceClassName
();
if
(
enhanceClassName
==
null
){
continue
;
}
if
(
enhanceClassName
.
endsWith
(
"*"
))
{
// 加上. 为了区分 com.ai.test com.ai.test1
blurryClassEnhancePluginDefineMapping
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/TracingBootstrap.java
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.plugin
;
import
com.ai.cloud.skywalking.conf.AuthDesc
;
import
com.ai.cloud.skywalking.logging.LogManager
;
import
com.ai.cloud.skywalking.logging.Logger
;
import
net.bytebuddy.ByteBuddy
;
...
...
@@ -31,6 +32,10 @@ public class TracingBootstrap {
throw
new
RuntimeException
(
"bootstrap failure. need args[0] to be main class."
);
}
if
(!
AuthDesc
.
isAuth
()){
return
;
}
List
<
AbstractClassEnhancePluginDefine
>
plugins
=
null
;
try
{
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassInstanceMethodsInterceptor.java
浏览文件 @
f50566dc
...
...
@@ -28,7 +28,7 @@ public class ClassInstanceMethodsInterceptor {
@FieldValue
(
ClassEnhancePluginDefine
.
contextAttrName
)
EnhancedClassInstanceContext
instanceContext
)
throws
Exception
{
InstanceMethodsAroundInterceptor
interceptor
=
InterceptorInstanceLoader
.
load
(
instanceMethodsAroundInterceptorClassName
,
obj
.
getClass
().
getClassLoader
());
InstanceMethodInvokeContext
interceptorContext
=
new
InstanceMethodInvokeContext
(
obj
,
method
.
getName
(),
allArguments
);
InstanceMethodInvokeContext
interceptorContext
=
new
InstanceMethodInvokeContext
(
obj
,
method
.
getName
(),
allArguments
,
method
.
getParameterTypes
()
);
MethodInterceptResult
result
=
new
MethodInterceptResult
();
try
{
interceptor
.
beforeMethod
(
instanceContext
,
interceptorContext
,
result
);
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/ClassStaticMethodsInterceptor.java
浏览文件 @
f50566dc
...
...
@@ -29,7 +29,7 @@ public class ClassStaticMethodsInterceptor {
public
Object
intercept
(
@Origin
Class
<?>
clazz
,
@AllArguments
Object
[]
allArguments
,
@Origin
Method
method
,
@SuperCall
Callable
<?>
zuper
)
throws
Exception
{
StaticMethodsAroundInterceptor
interceptor
=
InterceptorInstanceLoader
.
load
(
staticMethodsAroundInterceptorClassName
,
clazz
.
getClassLoader
());
MethodInvokeContext
interceptorContext
=
new
MethodInvokeContext
(
clazz
,
method
.
getName
(),
allArguments
);
StaticMethodInvokeContext
interceptorContext
=
new
StaticMethodInvokeContext
(
clazz
,
method
.
getName
(),
allArguments
,
method
.
getParameterTypes
()
);
MethodInterceptResult
result
=
new
MethodInterceptResult
();
try
{
interceptor
.
beforeMethod
(
interceptorContext
,
result
);
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/InstanceMethodInvokeContext.java
浏览文件 @
f50566dc
...
...
@@ -6,8 +6,8 @@ public class InstanceMethodInvokeContext extends MethodInvokeContext {
*/
private
Object
objInst
;
InstanceMethodInvokeContext
(
Object
objInst
,
String
methodName
,
Object
[]
allArguments
)
{
super
(
objInst
.
getClass
(),
methodName
,
allArgument
s
);
InstanceMethodInvokeContext
(
Object
objInst
,
String
methodName
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
)
{
super
(
methodName
,
allArguments
,
argumentsType
s
);
this
.
objInst
=
objInst
;
}
...
...
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/MethodInvokeContext.java
浏览文件 @
f50566dc
...
...
@@ -15,9 +15,12 @@ public class MethodInvokeContext {
*/
private
Object
[]
allArguments
;
MethodInvokeContext
(
Class
clazz
,
String
methodName
,
Object
[]
allArguments
)
{
this
.
methodName
=
appendMethodName
(
clazz
,
methodName
,
allArguments
);
private
Class
<?>[]
argumentTypes
;
MethodInvokeContext
(
String
methodName
,
Object
[]
allArguments
,
Class
<?>[]
argumentTypes
)
{
this
.
methodName
=
methodName
;
this
.
allArguments
=
allArguments
;
this
.
argumentTypes
=
argumentTypes
;
}
public
Object
[]
allArguments
()
{
...
...
@@ -28,17 +31,8 @@ public class MethodInvokeContext {
return
methodName
;
}
private
String
appendMethodName
(
Class
clazz
,
String
simpleMethodName
,
Object
[]
allArguments
)
{
StringBuilder
methodName
=
new
StringBuilder
(
clazz
.
getName
()
+
"."
+
simpleMethodName
+
"("
);
for
(
Object
argument
:
allArguments
)
{
methodName
.
append
(
argument
.
getClass
()
+
","
);
}
if
(
allArguments
.
length
>
0
){
methodName
.
deleteCharAt
(
methodName
.
length
()
-
1
);
}
methodName
.
append
(
")"
);
return
methodName
.
toString
();
public
Class
<?>[]
argumentTypes
(){
return
argumentTypes
;
}
}
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodInvokeContext.java
0 → 100644
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.plugin.interceptor.enhance
;
public
class
StaticMethodInvokeContext
extends
MethodInvokeContext
{
/**
* 代理类名
*/
private
Class
clazz
;
StaticMethodInvokeContext
(
Class
clazz
,
String
methodName
,
Object
[]
allArguments
,
Class
<?>[]
parameterTypes
)
{
super
(
methodName
,
allArguments
,
parameterTypes
);
this
.
clazz
=
clazz
;
}
public
Class
claszz
()
{
return
clazz
;
}
}
skywalking-collector/skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/enhance/StaticMethodsAroundInterceptor.java
浏览文件 @
f50566dc
...
...
@@ -2,9 +2,9 @@ package com.ai.cloud.skywalking.plugin.interceptor.enhance;
public
interface
StaticMethodsAroundInterceptor
{
public
void
beforeMethod
(
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
);
public
void
beforeMethod
(
Static
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
);
public
Object
afterMethod
(
MethodInvokeContext
interceptorContext
,
Object
ret
);
public
Object
afterMethod
(
Static
MethodInvokeContext
interceptorContext
,
Object
ret
);
public
void
handleMethodException
(
Throwable
t
,
MethodInvokeContext
interceptorContext
);
}
skywalking-collector/skywalking-api/src/test/java/test/ai/cloud/plugin/TestStaticAroundInterceptor.java
浏览文件 @
f50566dc
...
...
@@ -2,17 +2,18 @@ package test.ai.cloud.plugin;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInvokeContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodInvokeContext
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.StaticMethodsAroundInterceptor
;
public
class
TestStaticAroundInterceptor
implements
StaticMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
public
void
beforeMethod
(
Static
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
System
.
out
.
println
(
"beforeMethod : static"
);
}
@Override
public
Object
afterMethod
(
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
public
Object
afterMethod
(
Static
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
System
.
out
.
println
(
"afterMethod: static"
);
return
ret
;
}
...
...
skywalking-collector/skywalking-api/src/test/resources/sky-walking.auth
浏览文件 @
f50566dc
...
...
@@ -46,3 +46,9 @@ buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
#自定义本地方法插件是否开启
plugin.customlocalmethodinterceptorplugin.is_enable=true
#自定义插件拦截的包前缀
plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.test.*
#自定义插件是否记录入参
plugin.customlocalmethodinterceptorplugin.record_param_enable=false
skywalking-collector/skywalking-sdk-plugin/
self-define
-interceptor-plugin/pom.xml
→
skywalking-collector/skywalking-sdk-plugin/
custom-local-method
-interceptor-plugin/pom.xml
浏览文件 @
f50566dc
...
...
@@ -7,10 +7,10 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
self-define
-interceptor-plugin
</artifactId>
<artifactId>
custom-local-method
-interceptor-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
self-define
-interceptor-plugin
</name>
<name>
custom-local-method
-interceptor-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
...
...
skywalking-collector/skywalking-sdk-plugin/
self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefine
MethodInterceptor.java
→
skywalking-collector/skywalking-sdk-plugin/
custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocal
MethodInterceptor.java
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.
self.define.plugin
;
package
com.ai.cloud.skywalking.
plugin.custom.localmethod
;
import
com.ai.cloud.skywalking.conf.Config
;
import
com.ai.cloud.skywalking.invoke.monitor.LocalMethodInvokeMonitor
;
...
...
@@ -7,7 +7,7 @@ import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.*
;
import
com.google.gson.Gson
;
public
class
SelfDefine
MethodInterceptor
implements
InstanceMethodsAroundInterceptor
,
StaticMethodsAroundInterceptor
{
public
class
CustomLocal
MethodInterceptor
implements
InstanceMethodsAroundInterceptor
,
StaticMethodsAroundInterceptor
{
@Override
public
void
onConstruct
(
EnhancedClassInstanceContext
context
,
ConstructorInvokeContext
interceptorContext
)
{
...
...
@@ -17,12 +17,15 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
public
void
beforeMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
Identification
.
IdentificationBuilder
identificationBuilder
=
buildIdentificationBuilder
(
interceptorContext
);
identificationBuilder
.
spanType
(
new
CustomLocalSpanType
()).
viewPoint
(
fullMethodName
(
interceptorContext
.
inst
().
getClass
(),
interceptorContext
.
methodName
(),
interceptorContext
.
argumentTypes
()));
new
LocalMethodInvokeMonitor
().
beforeInvoke
(
identificationBuilder
.
build
());
}
private
Identification
.
IdentificationBuilder
buildIdentificationBuilder
(
MethodInvokeContext
interceptorContext
)
{
Identification
.
IdentificationBuilder
identificationBuilder
=
Identification
.
newBuilder
();
if
(
Config
.
SkyWalking
.
RECORD_PARAM
)
{
if
(
Config
.
Plugin
.
CustomLocalMethodInterceptorPlugin
.
RECORD_PARAM_ENABLE
)
{
for
(
Object
param
:
interceptorContext
.
allArguments
())
{
String
paramStr
;
try
{
...
...
@@ -34,7 +37,6 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
}
}
identificationBuilder
.
spanType
(
new
SelfDefineSpanType
()).
viewPoint
(
interceptorContext
.
methodName
());
return
identificationBuilder
;
}
...
...
@@ -51,13 +53,18 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
new
LocalMethodInvokeMonitor
().
occurException
(
t
);
}
@Override
public
void
beforeMethod
(
MethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
new
LocalMethodInvokeMonitor
().
beforeInvoke
(
buildIdentificationBuilder
(
interceptorContext
).
build
());
public
void
beforeMethod
(
StaticMethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
Identification
.
IdentificationBuilder
identificationBuilder
=
buildIdentificationBuilder
(
interceptorContext
);
identificationBuilder
.
spanType
(
new
CustomLocalSpanType
()).
viewPoint
(
fullMethodName
(
interceptorContext
.
claszz
(),
interceptorContext
.
methodName
(),
interceptorContext
.
argumentTypes
()));
new
LocalMethodInvokeMonitor
().
beforeInvoke
(
identificationBuilder
.
build
());
}
@Override
public
Object
afterMethod
(
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
public
Object
afterMethod
(
Static
MethodInvokeContext
interceptorContext
,
Object
ret
)
{
new
LocalMethodInvokeMonitor
().
afterInvoke
();
return
ret
;
}
...
...
@@ -66,4 +73,18 @@ public class SelfDefineMethodInterceptor implements InstanceMethodsAroundInterce
public
void
handleMethodException
(
Throwable
t
,
MethodInvokeContext
interceptorContext
)
{
new
LocalMethodInvokeMonitor
().
occurException
(
t
);
}
private
String
fullMethodName
(
Class
clazz
,
String
simpleMethodName
,
Object
[]
allArguments
)
{
StringBuilder
methodName
=
new
StringBuilder
(
clazz
.
getName
()
+
"."
+
simpleMethodName
+
"("
);
for
(
Object
argument
:
allArguments
)
{
methodName
.
append
(
argument
.
getClass
()
+
","
);
}
if
(
allArguments
.
length
>
0
)
{
methodName
.
deleteCharAt
(
methodName
.
length
()
-
1
);
}
methodName
.
append
(
")"
);
return
methodName
.
toString
();
}
}
skywalking-collector/skywalking-sdk-plugin/
self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/SelfDefine
SpanType.java
→
skywalking-collector/skywalking-sdk-plugin/
custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocal
SpanType.java
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.
self.define.plugin
;
package
com.ai.cloud.skywalking.
plugin.custom.localmethod
;
import
com.ai.cloud.skywalking.api.IBuriedPointType
;
import
com.ai.cloud.skywalking.protocol.common.CallType
;
public
class
SelfDefine
SpanType
implements
IBuriedPointType
{
public
class
CustomLocal
SpanType
implements
IBuriedPointType
{
@Override
public
String
getTypeName
()
{
return
"L"
;
...
...
skywalking-collector/skywalking-sdk-plugin/
self-define-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/self/define/plugin/define/SelfDefine
MethodPluginDefine.java
→
skywalking-collector/skywalking-sdk-plugin/
custom-local-method-interceptor-plugin/src/main/java/com/ai/cloud/skywalking/plugin/custom/localmethod/define/CustomLocal
MethodPluginDefine.java
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.
self.define.plugin
.define
;
package
com.ai.cloud.skywalking.
plugin.custom.localmethod
.define
;
import
com.ai.cloud.skywalking.conf.Config
;
import
com.ai.cloud.skywalking.plugin.PluginException
;
import
com.ai.cloud.skywalking.plugin.interceptor.MethodMatcher
;
import
com.ai.cloud.skywalking.plugin.interceptor.enhance.ClassEnhancePluginDefine
;
import
com.ai.cloud.skywalking.plugin.interceptor.matcher.AnyMethodsMatcher
;
import
net.bytebuddy.dynamic.DynamicType
;
public
class
SelfDefineMethodPluginDefine
extends
ClassEnhancePluginDefine
{
@Override
protected
DynamicType
.
Builder
<?>
enhance
(
String
enhanceOriginClassName
,
DynamicType
.
Builder
<?>
newClassBuilder
)
throws
PluginException
{
return
Config
.
SkyWalking
.
SELF_DEFINE_METHOD_INTERCEPTOR
?
super
.
enhance
(
enhanceOriginClassName
,
newClassBuilder
)
:
newClassBuilder
;
}
public
class
CustomLocalMethodPluginDefine
extends
ClassEnhancePluginDefine
{
@Override
protected
MethodMatcher
[]
getInstanceMethodsMatchers
()
{
...
...
@@ -24,7 +14,7 @@ public class SelfDefineMethodPluginDefine extends ClassEnhancePluginDefine {
@Override
protected
String
getInstanceMethodsInterceptor
()
{
return
"com.ai.cloud.skywalking.
self.define.plugin.SelfDefine
MethodInterceptor"
;
return
"com.ai.cloud.skywalking.
plugin.custom.localmethod.CustomLocal
MethodInterceptor"
;
}
@Override
...
...
@@ -34,14 +24,15 @@ public class SelfDefineMethodPluginDefine extends ClassEnhancePluginDefine {
@Override
protected
String
getStaticMethodsInterceptor
()
{
return
"com.ai.cloud.skywalking.
self.define.plugin.SelfDefine
MethodInterceptor"
;
return
"com.ai.cloud.skywalking.
plugin.custom.localmethod.CustomLocal
MethodInterceptor"
;
}
@Override
protected
String
enhanceClassName
()
{
if
(!
Config
.
SkyWalking
.
SELF_DEFINE_METHOD_PACKAGE
.
endsWith
(
".*"
))
{
return
Config
.
SkyWalking
.
SELF_DEFINE_METHOD_PACKAGE
+
".*"
;
}
return
Config
.
SkyWalking
.
SELF_DEFINE_METHOD_PACKAGE
;
return
"test.com.ai.test.TestObject"
;
// if (!Config.Plugin.CustomLocalMethodInterceptorPlugin.IS_ENABLE){
// return null;
// }
// return Config.Plugin.CustomLocalMethodInterceptorPlugin.PACKAGE_PREFIX;
}
}
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
f50566dc
com.ai.cloud.skywalking.plugin.custom.localmethod.define.CustomLocalMethodPluginDefine
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/com/ai/cloud/skywalking/plugin/custom/localmethod/CustomLocalMethodPluginTest.java
0 → 100644
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.plugin.custom.localmethod
;
import
com.ai.cloud.skywalking.plugin.TracingBootstrap
;
import
com.ai.skywalking.testframework.api.RequestSpanAssert
;
import
org.junit.Test
;
import
test.com.ai.test.TestObject
;
import
test.com.ai.test.TestParam
;
import
java.lang.reflect.InvocationTargetException
;
public
class
CustomLocalMethodPluginTest
{
@Test
public
void
test
()
throws
ClassNotFoundException
,
NoSuchMethodException
,
IllegalAccessException
,
InvocationTargetException
{
TracingBootstrap
.
main
(
new
String
[]{
"com.ai.cloud.skywalking.plugin.custom.localmethod.CustomLocalMethodPluginTest"
});
}
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
TestObject
testObject
=
new
TestObject
();
testObject
.
printlnHelloWorld
();
TestObject
.
staticPrintlnHelloWorld
(
"AA"
,
new
TestParam
());
RequestSpanAssert
.
assertEquals
(
new
String
[][]
{
{
"0"
,
"test.com.ai.test.TestObject.printlnHelloWorld()"
,
""
},
{
"0"
,
"test.com.ai.test.TestObject.staticPrintlnHelloWorld()"
,
""
}
});
}
}
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestObject.java
0 → 100644
浏览文件 @
f50566dc
package
test.com.ai.test
;
public
class
TestObject
{
public
static
void
staticPrintlnHelloWorld
(
String
aa
,
TestParam
param
){
System
.
out
.
println
(
"Hello World"
+
aa
);
}
public
void
printlnHelloWorld
(
TestParam
...
params
){
System
.
out
.
println
(
"Hello World"
);
}
}
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/java/test/com/ai/test/TestParam.java
0 → 100644
浏览文件 @
f50566dc
package
test.com.ai.test
;
/**
* Created by xin on 16/8/12.
*/
public
class
TestParam
{
}
skywalking-collector/skywalking-sdk-plugin/custom-local-method-interceptor-plugin/src/test/resources/sky-walking.auth
0 → 100644
浏览文件 @
f50566dc
#skyWalking用户ID
skywalking.user_id=123
#skyWalking应用编码
skywalking.application_code=skywalking-sample-dubbo
#skywalking auth的环境变量名字
skywalking.auth_system_env_name=SKYWALKING_RUN
#skywalking数据编码
skywalking.charset=UTF-8
skywalking.auth_override=true
#是否使用STD替换日志输出
skywalking.logger_std_out_override=false;
#是否打印数据
buriedpoint.printf=true
#埋点异常的最大长度
buriedpoint.max_exception_stack_length=4000
#业务字段的最大长度
buriedpoint.businesskey_max_length=300
#过滤异常
buriedpoint.exclusive_exceptions=java.lang.RuntimeException
#最大发送者的连接数阀比例
sender.connect_percent=100
#发送服务端配置
sender.servers_addr=127.0.0.1:34000
#最大发送的副本数量
sender.max_copy_num=2
#发送的最大长度
sender.max_send_length=20000
#当没有Sender时,尝试获取sender的等待周期
sender.retry_get_sender_wait_interval=2000
#最大消费线程数
consumer.max_consumer=1
#消费者最大等待时间
consumer.max_wait_time=5
#发送失败等待时间
consumer.consumer_fail_retry_wait_interval=50
#每个Buffer的最大个数
buffer.buffer_max_size=18000
#Buffer池的最大长度
buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
#自定义本地方法插件是否开启
plugin.customlocalmethodinterceptorplugin.is_enable=true
#自定义插件拦截的包前缀
plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.test.*
#自定义插件是否记录入参
plugin.customlocalmethodinterceptorplugin.record_param_enable=true
skywalking-collector/skywalking-sdk-plugin/pom.xml
浏览文件 @
f50566dc
...
...
@@ -16,7 +16,7 @@
<module>
httpClient-4.x-plugin
</module>
<module>
jedis-2.x-plugin
</module>
<module>
tomcat-7.x-8.x-plugin
</module>
<module>
self-define
-interceptor-plugin
</module>
<module>
custom-local-method
-interceptor-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
skywalking-collector/skywalking-sdk-plugin/self-define-interceptor-plugin/src/main/resources/skywalking-plugin.def
已删除
100644 → 0
浏览文件 @
fa2fdb4e
com.ai.cloud.skywalking.self.define.plugin.define.SelfDefineMethodPluginDefine
skywalking-protocol/src/main/java/com/ai/cloud/skywalking/protocol/RequestSpan.java
浏览文件 @
f50566dc
...
...
@@ -111,6 +111,7 @@ public class RequestSpan extends AbstractDataSerializable {
public
RequestSpan
()
{
}
private
boolean
isEntrySpan
()
{
return
"0"
.
equals
(
this
.
getParentLevel
()
+
this
.
getLevelId
());
}
...
...
@@ -214,7 +215,7 @@ public class RequestSpan extends AbstractDataSerializable {
TraceProtocol
.
RequestSpan
.
newBuilder
().
setTraceId
(
traceId
).
setParentLevel
(
parentLevel
)
.
setLevelId
(
levelId
).
setViewPointId
(
viewPointId
).
setStartDate
(
startDate
)
.
setSpanType
(
spanType
.
getValue
()).
setSpanTypeDesc
(
spanTypeDesc
).
setAddress
(
address
)
.
setProcessNo
(
processNo
);
.
setProcessNo
(
processNo
);
if
(
businessKey
!=
null
&&
businessKey
.
length
()
>
0
)
{
builder
.
setBussinessKey
(
businessKey
);
}
...
...
@@ -246,6 +247,7 @@ public class RequestSpan extends AbstractDataSerializable {
requestSpan
.
setAgentId
(
requestSpanByte
.
getAgentId
());
requestSpan
.
setProcessNo
(
requestSpanByte
.
getProcessNo
());
requestSpan
.
setAddress
(
requestSpanByte
.
getAddress
());
requestSpan
.
setParameters
(
requestSpanByte
.
getParametersMap
());
}
catch
(
InvalidProtocolBufferException
e
)
{
throw
new
ConvertFailedException
(
e
.
getMessage
(),
e
);
}
...
...
@@ -254,7 +256,7 @@ public class RequestSpan extends AbstractDataSerializable {
}
public
static
RequestSpan
convert
(
byte
[]
data
)
throws
ConvertFailedException
{
return
(
RequestSpan
)
INSTANCE
.
convertData
(
data
);
return
(
RequestSpan
)
INSTANCE
.
convertData
(
data
);
}
public
void
setBusinessKey
(
String
businessKey
)
{
...
...
@@ -310,10 +312,7 @@ public class RequestSpan extends AbstractDataSerializable {
}
public
RequestSpanBuilder
parameters
(
Map
<
String
,
String
>
parameters
)
{
if
(
requestSpan
.
isEntrySpan
())
{
requestSpan
.
parameters
=
parameters
;
}
requestSpan
.
parameters
=
parameters
;
return
this
;
}
...
...
@@ -326,12 +325,12 @@ public class RequestSpan extends AbstractDataSerializable {
return
this
;
}
public
RequestSpanBuilder
processNo
(
String
processNo
){
public
RequestSpanBuilder
processNo
(
String
processNo
)
{
requestSpan
.
processNo
=
processNo
;
return
this
;
}
public
RequestSpanBuilder
address
(
String
address
){
public
RequestSpanBuilder
address
(
String
address
)
{
requestSpan
.
address
=
address
;
return
this
;
}
...
...
test/skywalking-agent-test/agent/sky-walking.auth
0 → 100644
浏览文件 @
f50566dc
#skyWalking用户ID
skywalking.user_id=123
#skyWalking应用编码
skywalking.application_code=skywalking-sample-dubbo
#skywalking auth的环境变量名字
skywalking.auth_system_env_name=SKYWALKING_RUN
#skywalking数据编码
skywalking.charset=UTF-8
skywalking.auth_override=true
#是否使用STD替换日志输出
skywalking.logger_std_out_override=false;
#是否打印数据
buriedpoint.printf=true
#埋点异常的最大长度
buriedpoint.max_exception_stack_length=4000
#业务字段的最大长度
buriedpoint.businesskey_max_length=300
#过滤异常
buriedpoint.exclusive_exceptions=java.lang.RuntimeException
#最大发送者的连接数阀比例
sender.connect_percent=100
#发送服务端配置
sender.servers_addr=127.0.0.1:34000
#最大发送的副本数量
sender.max_copy_num=2
#发送的最大长度
sender.max_send_length=20000
#当没有Sender时,尝试获取sender的等待周期
sender.retry_get_sender_wait_interval=2000
#最大消费线程数
consumer.max_consumer=0
#消费者最大等待时间
consumer.max_wait_time=5
#发送失败等待时间
consumer.consumer_fail_retry_wait_interval=50
#每个Buffer的最大个数
buffer.buffer_max_size=18000
#Buffer池的最大长度
buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
#自定义本地方法插件是否开启
plugin.customlocalmethodinterceptorplugin.is_enable=true
#自定义插件拦截的包前缀
plugin.customlocalmethodinterceptorplugin.package_prefix=test.com.ai.cloud.skywalking.agent.test.custom.localmethod.*
#自定义插件是否记录入参
plugin.customlocalmethodinterceptorplugin.record_param_enable=true
test/skywalking-agent-test/custom-local-method-test/pom.xml
0 → 100644
浏览文件 @
f50566dc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
skywalking-agent-test
</artifactId>
<groupId>
com.ai.cloud
</groupId>
<version>
1.0-Final
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
custom-local-method-test
</artifactId>
</project>
test/skywalking-agent-test/custom-local-method-test/src/main/java/com/ai/cloud/skywalking/agent/test/custom/localmethod/CustomLocalMethodPluginTest.java
0 → 100644
浏览文件 @
f50566dc
package
com.ai.cloud.skywalking.agent.test.custom.localmethod
;
import
com.ai.skywalking.testframework.api.RequestSpanAssert
;
import
test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject
;
import
test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestParam
;
public
class
CustomLocalMethodPluginTest
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
{
TestObject
testObject
=
new
TestObject
();
TestObject
.
staticPrintlnHelloWorld
(
"AAAA"
,
new
TestParam
(
"A"
,
"B"
));
testObject
.
printlnHelloWorld
(
new
TestParam
(
"B"
,
"C"
));
RequestSpanAssert
.
assertEquals
(
new
String
[][]
{
{
"0"
,
"test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject.printlnHelloWorld()"
,
""
},
{
"0"
,
"test.com.ai.cloud.skywalking.agent.test.custom.localmethod.TestObject.staticPrintlnHelloWorld()"
,
""
}
},
true
);
}
}
test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestObject.java
0 → 100644
浏览文件 @
f50566dc
package
test.com.ai.cloud.skywalking.agent.test.custom.localmethod
;
public
class
TestObject
{
public
static
void
staticPrintlnHelloWorld
(
String
aa
,
TestParam
param
){
System
.
out
.
println
(
"Hello World"
+
aa
);
}
public
void
printlnHelloWorld
(
TestParam
...
params
){
System
.
out
.
println
(
"Hello World"
);
}
}
test/skywalking-agent-test/custom-local-method-test/src/main/java/test/com/ai/cloud/skywalking/agent/test/custom/localmethod/TestParam.java
0 → 100644
浏览文件 @
f50566dc
package
test.com.ai.cloud.skywalking.agent.test.custom.localmethod
;
/**
* Created by xin on 16/8/12.
*/
public
class
TestParam
{
private
String
a
;
private
String
b
;
public
TestParam
(
String
a
,
String
b
)
{
this
.
a
=
a
;
this
.
b
=
b
;
}
}
test/skywalking-agent-test/pom.xml
浏览文件 @
f50566dc
...
...
@@ -13,7 +13,7 @@
<modules>
<module>
redis-test
</module>
<module>
jdbc-test
</module>
<module>
dubbo
-test
</module>
<module>
custom-local-method
-test
</module>
</modules>
<properties>
...
...
@@ -36,7 +36,6 @@
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-test-api
</artifactId>
<version>
1.0-Final
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录