Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
ee6841fc
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
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,发现更多精彩内容 >>
提交
ee6841fc
编写于
1月 03, 2019
作者:
X
XiaoFu
提交者:
wu-sheng
1月 03, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support Gson Plugin (#2090)
* Support Gson plugin
上级
0a3af743
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
519 addition
and
2 deletion
+519
-2
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
...walking/apm/network/trace/component/ComponentsDefine.java
+4
-1
apm-sniffer/apm-sdk-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/pom.xml
+1
-1
apm-sniffer/optional-plugins/gson-2.8.x-plugin/pom.xml
apm-sniffer/optional-plugins/gson-2.8.x-plugin/pom.xml
+45
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/GsonFromJsonInterceptor.java
...e/skywalking/apm/plugin/gson/GsonFromJsonInterceptor.java
+62
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/GsonToJsonInterceptor.java
...che/skywalking/apm/plugin/gson/GsonToJsonInterceptor.java
+61
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/define/GsonFromJsonInstrumentation.java
...g/apm/plugin/gson/define/GsonFromJsonInstrumentation.java
+71
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/define/GsonToJsonInstrumentation.java
...ing/apm/plugin/gson/define/GsonToJsonInstrumentation.java
+88
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/resources/skywalking-plugin.def
...son-2.8.x-plugin/src/main/resources/skywalking-plugin.def
+18
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/gson/GsonFromJsonInterceptorTest.java
...ywalking/apm/plugin/gson/GsonFromJsonInterceptorTest.java
+80
-0
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/gson/GsonToJsonInterceptorTest.java
...skywalking/apm/plugin/gson/GsonToJsonInterceptorTest.java
+79
-0
apm-sniffer/optional-plugins/pom.xml
apm-sniffer/optional-plugins/pom.xml
+1
-0
docker/config/component-libraries.yml
docker/config/component-libraries.yml
+3
-0
docs/en/setup/service-agent/java-agent/README.md
docs/en/setup/service-agent/java-agent/README.md
+1
-0
docs/en/setup/service-agent/java-agent/Supported-list.md
docs/en/setup/service-agent/java-agent/Supported-list.md
+2
-0
oap-server/server-starter/src/main/resources/component-libraries.yml
...server-starter/src/main/resources/component-libraries.yml
+3
-0
未找到文件。
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
浏览文件 @
ee6841fc
...
...
@@ -106,6 +106,8 @@ public class ComponentsDefine {
public
static
final
OfficialComponent
CANAL
=
new
OfficialComponent
(
54
,
"Canal"
);
public
static
final
OfficialComponent
GSON
=
new
OfficialComponent
(
55
,
"Gson"
);
private
static
ComponentsDefine
INSTANCE
=
new
ComponentsDefine
();
private
String
[]
components
;
...
...
@@ -115,7 +117,7 @@ public class ComponentsDefine {
}
public
ComponentsDefine
()
{
components
=
new
String
[
5
5
];
components
=
new
String
[
5
6
];
addComponent
(
TOMCAT
);
addComponent
(
HTTPCLIENT
);
addComponent
(
DUBBO
);
...
...
@@ -155,6 +157,7 @@ public class ComponentsDefine {
addComponent
(
RABBITMQ_PRODUCER
);
addComponent
(
RABBITMQ_CONSUMER
);
addComponent
(
CANAL
);
addComponent
(
GSON
);
}
private
void
addComponent
(
OfficialComponent
component
)
{
...
...
apm-sniffer/apm-sdk-plugin/pom.xml
浏览文件 @
ee6841fc
...
...
@@ -60,7 +60,7 @@
<module>
activemq-5.x-plugin
</module>
<module>
elasticsearch-5.x-plugin
</module>
<module>
undertow-plugins
</module>
<module>
rabbitmq-5.x-plugin
</module>
<module>
rabbitmq-5.x-plugin
</module>
<module>
dubbo-conflict-patch
</module>
<module>
canal-1.x-plugin
</module>
</modules>
...
...
apm-sniffer/optional-plugins/gson-2.8.x-plugin/pom.xml
0 → 100644
浏览文件 @
ee6841fc
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
optional-plugins
</artifactId>
<version>
6.0.0-GA-SNAPSHOT
</version>
</parent>
<artifactId>
apm-gson-2.x-plugin
</artifactId>
<name>
gson-2.8.x-plugin
</name>
<packaging>
jar
</packaging>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<gson.version>
2.8.5
</gson.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
${gson.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/GsonFromJsonInterceptor.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
java.lang.reflect.Method
;
/**
* @author withlin
*/
public
class
GsonFromJsonInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
"Gson/FromJson"
);
span
.
setComponent
(
ComponentsDefine
.
GSON
);
Integer
length
=
allArguments
[
0
].
toString
().
length
();
span
.
tag
(
"length"
,
length
.
toString
());
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
\ No newline at end of file
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/GsonToJsonInterceptor.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
java.lang.reflect.Method
;
/**
* @author withlin
*/
public
class
GsonToJsonInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
"Gson/ToJson"
);
span
.
setComponent
(
ComponentsDefine
.
GSON
);
Integer
length
=
allArguments
[
0
].
toString
().
length
();
span
.
tag
(
"length"
,
length
.
toString
());
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/define/GsonFromJsonInstrumentation.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
/**
* @author withlin
*/
public
class
GsonFromJsonInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
INTERCEPTOR_CLASS
=
"org.apache.skywalking.apm.plugin.gson.GsonFromJsonInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"com.google.gson.Gson"
;
public
static
final
String
ENHANCE_METHOD_DISPATCH
=
"fromJson"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD_DISPATCH
)
.
and
(
takesArgumentWithType
(
0
,
"com.google.gson.stream.JsonReader"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
MultiClassNameMatch
.
byMultiClassMatch
(
ENHANCE_CLASS
);
}
}
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/gson/define/GsonToJsonInstrumentation.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
/**
* @author withlin
*/
public
class
GsonToJsonInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
INTERCEPTOR_CLASS
=
"org.apache.skywalking.apm.plugin.gson.GsonToJsonInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"com.google.gson.Gson"
;
public
static
final
String
ENHANCE_METHOD
=
"toJson"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD
)
.
and
(
takesArgumentWithType
(
2
,
"com.google.gson.stream.JsonWriter"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD
)
.
and
(
takesArgumentWithType
(
1
,
"com.google.gson.stream.JsonWriter"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
MultiClassNameMatch
.
byMultiClassMatch
(
ENHANCE_CLASS
);
}
}
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
ee6841fc
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
gson-2.8.x=org.apache.skywalking.apm.plugin.gson.define.GsonToJsonInstrumentation
gson-2.8.x=org.apache.skywalking.apm.plugin.gson.define.GsonFromJsonInstrumentation
\ No newline at end of file
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/gson/GsonFromJsonInterceptorTest.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.apache.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
import
java.util.List
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
public
class
GsonFromJsonInterceptorTest
{
private
GsonFromJsonInterceptor
gsonFromJsonInterceptor
;
@SegmentStoragePoint
private
SegmentStorage
segmentStorage
;
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
private
Object
[]
arguments
;
private
Class
[]
argumentType
;
@Before
public
void
setUp
()
{
gsonFromJsonInterceptor
=
new
GsonFromJsonInterceptor
();
arguments
=
new
Object
[]
{
"100"
};
}
@Test
public
void
testSendMessage
()
throws
Throwable
{
gsonFromJsonInterceptor
.
beforeMethod
(
null
,
null
,
arguments
,
null
,
null
);
gsonFromJsonInterceptor
.
afterMethod
(
null
,
null
,
arguments
,
null
,
null
);
List
<
TraceSegment
>
traceSegmentList
=
segmentStorage
.
getTraceSegments
();
assertThat
(
traceSegmentList
.
size
(),
is
(
1
));
TraceSegment
segment
=
traceSegmentList
.
get
(
0
);
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
segment
);
assertThat
(
spans
.
size
(),
is
(
1
));
}
}
\ No newline at end of file
apm-sniffer/optional-plugins/gson-2.8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/gson/GsonToJsonInterceptorTest.java
0 → 100644
浏览文件 @
ee6841fc
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.gson
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.apache.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
import
java.util.List
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
public
class
GsonToJsonInterceptorTest
{
private
GsonToJsonInterceptor
gsonToJsonInterceptor
;
@SegmentStoragePoint
private
SegmentStorage
segmentStorage
;
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
private
Object
[]
arguments
;
private
Class
[]
argumentType
;
@Before
public
void
setUp
()
{
gsonToJsonInterceptor
=
new
GsonToJsonInterceptor
();
arguments
=
new
Object
[]
{
"100"
};
}
@Test
public
void
testSendMessage
()
throws
Throwable
{
gsonToJsonInterceptor
.
beforeMethod
(
null
,
null
,
arguments
,
null
,
null
);
gsonToJsonInterceptor
.
afterMethod
(
null
,
null
,
arguments
,
null
,
null
);
List
<
TraceSegment
>
traceSegmentList
=
segmentStorage
.
getTraceSegments
();
assertThat
(
traceSegmentList
.
size
(),
is
(
1
));
TraceSegment
segment
=
traceSegmentList
.
get
(
0
);
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
segment
);
assertThat
(
spans
.
size
(),
is
(
1
));
}
}
apm-sniffer/optional-plugins/pom.xml
浏览文件 @
ee6841fc
...
...
@@ -43,6 +43,7 @@
<modules>
<module>
optional-spring-plugins
</module>
<module>
trace-ignore-plugin
</module>
<module>
gson-2.8.x-plugin
</module>
</modules>
<dependencies>
...
...
docker/config/component-libraries.yml
浏览文件 @
ee6841fc
...
...
@@ -189,6 +189,9 @@ rabbitmq-consumer:
Canal
:
id
:
54
languages
:
Java
Gson
:
id
:
55
languages
:
Java
# .NET/.NET Core components
# [3000, 4000) for C#/.NET only
...
...
docs/en/setup/service-agent/java-agent/README.md
浏览文件 @
ee6841fc
...
...
@@ -86,6 +86,7 @@ Now, we have the following known optional plugins.
*
[
Trace Spring beans
](
agent-optional-plugins/Spring-bean-plugins.md
)
*
[
Trace Oracle and Resin
](
agent-optional-plugins/Oracle-Resin-plugins.md
)
*
[
Filter traces through specified endpoint name patterns
](
agent-optional-plugins/trace-ignore-plugin.md
)
*
Gson serialization lib in optional plugin folder
## Advanced Features
*
Set the settings through system properties for config file override. Read
[
setting override
](
Setting-override.md
)
.
...
...
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
ee6841fc
...
...
@@ -56,6 +56,8 @@
*
[
Elastic Job
](
https://github.com/elasticjob/elastic-job
)
2.x
*
OpenTracing community supported
*
[
Canal: Alibaba mysql database binlog incremental subscription & consumer components
](
https://github.com/alibaba/canal
)
1.0.25 -> 1.1.2
*
JSON
*
[
GSON
](
https://github.com/google/gson
)
2.8.x (Optional²)
¹Due to license incompatibilities/restrictions these plugins are hosted and released in 3rd part repository,
go to
[
OpenSkywalking java plugin extension repository
](
https://github.com/OpenSkywalking/java-plugin-extensions
)
to get these.
...
...
oap-server/server-starter/src/main/resources/component-libraries.yml
浏览文件 @
ee6841fc
...
...
@@ -189,6 +189,9 @@ rabbitmq-consumer:
Canal
:
id
:
54
languages
:
Java
Gson
:
id
:
55
languages
:
Java
# .NET/.NET Core components
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录