Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
43b216aa
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,发现更多精彩内容 >>
提交
43b216aa
编写于
1月 11, 2019
作者:
于
于玉桔
提交者:
wu-sheng
1月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support redisson plugin (#2083)
* plugin support redisson
上级
9cc5e76d
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
650 addition
and
2 deletion
+650
-2
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
...walking/apm/network/trace/component/ComponentsDefine.java
+5
-2
apm-sniffer/apm-sdk-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/pom.xml
+1
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/pom.xml
+46
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
.../apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
+107
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisClientConstructorInterceptor.java
...plugin/redisson/v3/RedisClientConstructorInterceptor.java
+36
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisConnectionMethodInterceptor.java
.../plugin/redisson/v3/RedisConnectionMethodInterceptor.java
+113
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/ConnectionManagerInstrumentation.java
.../redisson/v3/define/ConnectionManagerInstrumentation.java
+72
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/RedisClientInstrumentation.java
...plugin/redisson/v3/define/RedisClientInstrumentation.java
+67
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/RedisConnectionInstrumentation.java
...in/redisson/v3/define/RedisConnectionInstrumentation.java
+85
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/resources/skywalking-plugin.def
...isson-3.x-plugin/src/main/resources/skywalking-plugin.def
+19
-0
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisConnectionMethodInterceptorTest.java
...gin/redisson/v3/RedisConnectionMethodInterceptorTest.java
+85
-0
docker/config/component-libraries.yml
docker/config/component-libraries.yml
+4
-0
docs/en/guides/Component-library-settings.md
docs/en/guides/Component-library-settings.md
+1
-0
docs/en/setup/service-agent/java-agent/Supported-list.md
docs/en/setup/service-agent/java-agent/Supported-list.md
+1
-0
oap-server/server-core/src/test/resources/component-libraries.yml
...er/server-core/src/test/resources/component-libraries.yml
+4
-0
oap-server/server-starter/src/main/resources/component-libraries.yml
...server-starter/src/main/resources/component-libraries.yml
+4
-0
未找到文件。
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
浏览文件 @
43b216aa
...
...
@@ -105,8 +105,10 @@ public class ComponentsDefine {
public
static
final
OfficialComponent
RABBITMQ_CONSUMER
=
new
OfficialComponent
(
53
,
"rabbitmq-consumer"
);
public
static
final
OfficialComponent
CANAL
=
new
OfficialComponent
(
54
,
"Canal"
);
public
static
final
OfficialComponent
GSON
=
new
OfficialComponent
(
55
,
"Gson"
);
public
static
final
OfficialComponent
REDISSON
=
new
OfficialComponent
(
56
,
"Redisson"
);
private
static
ComponentsDefine
INSTANCE
=
new
ComponentsDefine
();
...
...
@@ -117,7 +119,7 @@ public class ComponentsDefine {
}
public
ComponentsDefine
()
{
components
=
new
String
[
5
6
];
components
=
new
String
[
5
7
];
addComponent
(
TOMCAT
);
addComponent
(
HTTPCLIENT
);
addComponent
(
DUBBO
);
...
...
@@ -158,6 +160,7 @@ public class ComponentsDefine {
addComponent
(
RABBITMQ_CONSUMER
);
addComponent
(
CANAL
);
addComponent
(
GSON
);
addComponent
(
REDISSON
);
}
private
void
addComponent
(
OfficialComponent
component
)
{
...
...
apm-sniffer/apm-sdk-plugin/pom.xml
浏览文件 @
43b216aa
...
...
@@ -32,6 +32,7 @@
<module>
jdbc-commons
</module>
<module>
httpClient-4.x-plugin
</module>
<module>
jedis-2.x-plugin
</module>
<module>
redisson-3.x-plugin
</module>
<module>
tomcat-7.x-8.x-plugin
</module>
<module>
motan-plugin
</module>
<module>
mongodb-3.x-plugin
</module>
...
...
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/pom.xml
0 → 100644
浏览文件 @
43b216aa
<?xml version="1.0"?>
<!--
~ 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>
apm-sdk-plugin
</artifactId>
<version>
6.0.0-GA-SNAPSHOT
</version>
</parent>
<artifactId>
apm-redisson-3.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
redisson-3.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<redisson.version>
3.6.0
</redisson.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.redisson
</groupId>
<artifactId>
redisson
</artifactId>
<version>
${redisson.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3
;
import
org.apache.skywalking.apm.agent.core.logging.api.ILog
;
import
org.apache.skywalking.apm.agent.core.logging.api.LogManager
;
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.redisson.config.*
;
import
org.redisson.connection.ConnectionManager
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.net.URI
;
import
java.util.Collection
;
/**
* @author zhaoyuguang
*/
public
class
ConnectionManagerInterceptor
implements
InstanceMethodsAroundInterceptor
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
ConnectionManagerInterceptor
.
class
);
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
try
{
ConnectionManager
connectionManager
=
(
ConnectionManager
)
objInst
;
Config
config
=
connectionManager
.
getCfg
();
SentinelServersConfig
sentinelServersConfig
=
(
SentinelServersConfig
)
getServersConfig
(
config
,
"sentinelServersConfig"
);
MasterSlaveServersConfig
masterSlaveServersConfig
=
(
MasterSlaveServersConfig
)
getServersConfig
(
config
,
"masterSlaveServersConfig"
);
ClusterServersConfig
clusterServersConfig
=
(
ClusterServersConfig
)
getServersConfig
(
config
,
"clusterServersConfig"
);
ReplicatedServersConfig
replicatedServersConfig
=
(
ReplicatedServersConfig
)
getServersConfig
(
config
,
"replicatedServersConfig"
);
StringBuilder
peer
=
new
StringBuilder
();
EnhancedInstance
retInst
=
(
EnhancedInstance
)
ret
;
if
(
sentinelServersConfig
!=
null
)
{
appendAddresses
(
peer
,
sentinelServersConfig
.
getSentinelAddresses
());
retInst
.
setSkyWalkingDynamicField
(
peer
.
toString
());
return
ret
;
}
if
(
masterSlaveServersConfig
!=
null
)
{
URI
masterAddress
=
masterSlaveServersConfig
.
getMasterAddress
();
peer
.
append
(
masterAddress
.
getHost
()).
append
(
":"
).
append
(
masterAddress
.
getPort
());
appendAddresses
(
peer
,
masterSlaveServersConfig
.
getSlaveAddresses
());
retInst
.
setSkyWalkingDynamicField
(
peer
.
toString
());
return
ret
;
}
if
(
clusterServersConfig
!=
null
)
{
appendAddresses
(
peer
,
clusterServersConfig
.
getNodeAddresses
());
retInst
.
setSkyWalkingDynamicField
(
peer
.
toString
());
return
ret
;
}
if
(
replicatedServersConfig
!=
null
)
{
appendAddresses
(
peer
,
replicatedServersConfig
.
getNodeAddresses
());
retInst
.
setSkyWalkingDynamicField
(
peer
.
toString
());
return
ret
;
}
}
catch
(
Exception
e
)
{
logger
.
warn
(
"redisClient set peer error: "
,
e
);
}
return
ret
;
}
private
Object
getServersConfig
(
Config
config
,
String
fieldName
)
throws
NoSuchFieldException
,
IllegalAccessException
{
Field
field
=
config
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
field
.
get
(
config
);
}
private
void
appendAddresses
(
StringBuilder
peer
,
Collection
<
URI
>
nodeAddresses
)
{
if
(
nodeAddresses
!=
null
&&
!
nodeAddresses
.
isEmpty
())
{
for
(
URI
uri
:
nodeAddresses
)
{
peer
.
append
(
uri
.
getHost
()).
append
(
":"
).
append
(
uri
.
getPort
()).
append
(
";"
);
}
}
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisClientConstructorInterceptor.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
/**
* RedisClient is the link between RedisConnection and ConnectionManager.
* to enhance RedisClient for bring peer(the cluster configuration information) in ConnectionManager to RedisConnection.
*
* @author zhaoyuguang
*/
public
class
RedisClientConstructorInterceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisConnectionMethodInterceptor.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.Channel
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
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
org.redisson.client.RedisClient
;
import
org.redisson.client.RedisConnection
;
import
org.redisson.client.protocol.CommandData
;
import
org.redisson.client.protocol.CommandsData
;
import
java.lang.reflect.Method
;
import
java.net.InetSocketAddress
;
/**
* @author zhaoyuguang
*/
public
class
RedisConnectionMethodInterceptor
implements
InstanceMethodsAroundInterceptor
,
InstanceConstructorInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
String
peer
=
(
String
)
objInst
.
getSkyWalkingDynamicField
();
RedisConnection
connection
=
(
RedisConnection
)
objInst
;
Channel
channel
=
connection
.
getChannel
();
InetSocketAddress
remoteAddress
=
(
InetSocketAddress
)
channel
.
remoteAddress
();
String
dbInstance
=
remoteAddress
.
getAddress
().
getHostAddress
()
+
":"
+
remoteAddress
.
getPort
();
StringBuilder
dbStatement
=
new
StringBuilder
();
String
operationName
=
"Redisson/"
;
if
(
allArguments
[
0
]
instanceof
CommandsData
)
{
operationName
=
operationName
+
"BATCH_EXECUTE"
;
CommandsData
commands
=
(
CommandsData
)
allArguments
[
0
];
for
(
CommandData
commandData
:
commands
.
getCommands
())
{
addCommandData
(
dbStatement
,
commandData
);
dbStatement
.
append
(
";"
);
}
}
else
if
(
allArguments
[
0
]
instanceof
CommandData
)
{
CommandData
commandData
=
(
CommandData
)
allArguments
[
0
];
String
command
=
commandData
.
getCommand
().
getName
();
operationName
=
operationName
+
command
;
addCommandData
(
dbStatement
,
commandData
);
}
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
operationName
,
peer
);
span
.
setComponent
(
ComponentsDefine
.
REDISSON
);
Tags
.
DB_TYPE
.
set
(
span
,
"Redis"
);
Tags
.
DB_INSTANCE
.
set
(
span
,
dbInstance
);
Tags
.
DB_STATEMENT
.
set
(
span
,
dbStatement
.
toString
());
SpanLayer
.
asCache
(
span
);
}
private
void
addCommandData
(
StringBuilder
dbStatement
,
CommandData
commandData
)
{
dbStatement
.
append
(
commandData
.
getCommand
().
getName
());
if
(
commandData
.
getParams
()
!=
null
)
{
for
(
Object
param
:
commandData
.
getParams
())
{
dbStatement
.
append
(
" "
).
append
(
param
instanceof
ByteBuf
?
"?"
:
String
.
valueOf
(
param
.
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
)
{
AbstractSpan
span
=
ContextManager
.
activeSpan
();
span
.
errorOccurred
();
span
.
log
(
t
);
}
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
String
peer
=
(
String
)
((
EnhancedInstance
)
allArguments
[
0
]).
getSkyWalkingDynamicField
();
if
(
peer
==
null
)
{
peer
=
((
RedisClient
)
allArguments
[
0
]).
getConfig
().
getAddress
().
getAuthority
();
}
objInst
.
setSkyWalkingDynamicField
(
peer
);
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/ConnectionManagerInstrumentation.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3.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
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* @author zhaoyuguang
*/
public
class
ConnectionManagerInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"org.redisson.connection.MasterSlaveConnectionManager"
;
private
static
final
String
CONNECTION_MANAGER_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.redisson.v3.ConnectionManagerInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"createClient"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
CONNECTION_MANAGER_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/RedisClientInstrumentation.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3.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
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* @author zhaoyuguang
*/
public
class
RedisClientInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"org.redisson.client.RedisClient"
;
private
static
final
String
REDIS_CLIENT_CONSTRUCTOR_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.redisson.v3.RedisClientConstructorInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[]
{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
any
();
}
@Override
public
String
getConstructorInterceptor
()
{
return
REDIS_CLIENT_CONSTRUCTOR_INTERCEPTOR
;
}
}
};
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[
0
];
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/define/RedisConnectionInstrumentation.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3.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
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* @author zhaoyuguang
*/
public
class
RedisConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"org.redisson.client.RedisConnection"
;
private
static
final
String
REDISSON_METHOD_INTERCEPTOR_CLASS
=
"org.apache.skywalking.apm.plugin.redisson.v3.RedisConnectionMethodInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[]
{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
takesArgumentWithType
(
0
,
"org.redisson.client.RedisClient"
);
}
@Override
public
String
getConstructorInterceptor
()
{
return
REDISSON_METHOD_INTERCEPTOR_CLASS
;
}
}
};
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"send"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
REDISSON_METHOD_INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
43b216aa
# 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.
redisson-3.x=org.apache.skywalking.apm.plugin.redisson.v3.define.ConnectionManagerInstrumentation
redisson-3.x=org.apache.skywalking.apm.plugin.redisson.v3.define.RedisConnectionInstrumentation
redisson-3.x=org.apache.skywalking.apm.plugin.redisson.v3.define.RedisClientInstrumentation
\ No newline at end of file
apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/redisson/v3/RedisConnectionMethodInterceptorTest.java
0 → 100644
浏览文件 @
43b216aa
/*
* 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.redisson.v3
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
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.hamcrest.MatcherAssert
;
import
org.hamcrest.core.Is
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
/**
* @author zhaoyuguang
*/
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
public
class
RedisConnectionMethodInterceptorTest
{
@SegmentStoragePoint
private
SegmentStorage
segmentStorage
;
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
@Mock
private
MockInstance
mockRedisClientInstance
;
@Mock
private
MockInstance
mockRedisConnectionInstance
;
private
RedisConnectionMethodInterceptor
interceptor
;
private
class
MockInstance
implements
EnhancedInstance
{
private
Object
object
;
@Override
public
Object
getSkyWalkingDynamicField
()
{
return
object
;
}
@Override
public
void
setSkyWalkingDynamicField
(
Object
value
)
{
this
.
object
=
value
;
}
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@Before
public
void
setUp
()
throws
Exception
{
mockRedisConnectionInstance
=
new
MockInstance
();
mockRedisClientInstance
=
new
MockInstance
();
mockRedisClientInstance
.
setSkyWalkingDynamicField
(
"127.0.0.1:6379;127.0.0.1:6378;"
);
interceptor
=
new
RedisConnectionMethodInterceptor
();
}
@Test
public
void
testIntercept
()
throws
Throwable
{
interceptor
.
onConstruct
(
mockRedisConnectionInstance
,
new
Object
[]{
mockRedisClientInstance
});
MatcherAssert
.
assertThat
((
String
)
mockRedisConnectionInstance
.
getSkyWalkingDynamicField
(),
Is
.
is
(
"127.0.0.1:6379;127.0.0.1:6378;"
));
}
}
docker/config/component-libraries.yml
浏览文件 @
43b216aa
...
...
@@ -195,6 +195,9 @@ Canal:
Gson
:
id
:
55
languages
:
Java
Redisson
:
id
:
56
languages
:
Java
# .NET/.NET Core components
...
...
@@ -279,6 +282,7 @@ Component-Server-Mappings:
h2-jdbc-driver
:
H2
mysql-connector-java
:
Mysql
Jedis
:
Redis
Redisson
:
Redis
StackExchange.Redis
:
Redis
SqlClient
:
SqlServer
Npgsql
:
PostgreSQL
...
...
docs/en/guides/Component-library-settings.md
浏览文件 @
43b216aa
...
...
@@ -55,6 +55,7 @@ Remote server will be conjectured by the local component. The mappings are based
Component-Server-Mappings
:
Jedis
:
Redis
StackExchange.Redis
:
Redis
Redisson
:
Redis
SqlClient
:
SqlServer
Npgsql
:
PostgreSQL
MySqlConnector
:
Mysql
...
...
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
43b216aa
...
...
@@ -40,6 +40,7 @@
*
NoSQL
*
Redis
*
[
Jedis
](
https://github.com/xetorthio/jedis
)
2.x
*
[
Redisson
](
https://github.com/redisson/redisson
)
Easy Java Redis client 3.5.2+
*
[
MongoDB Java Driver
](
https://github.com/mongodb/mongo-java-driver
)
2.13-2.14,3.3+
*
Memcached Client
*
[
Spymemcached
](
https://github.com/couchbase/spymemcached
)
2.x
...
...
oap-server/server-core/src/test/resources/component-libraries.yml
浏览文件 @
43b216aa
...
...
@@ -177,6 +177,9 @@ transport-client:
Undertow
:
id
:
49
languages
:
Java
Redisson
:
id
:
56
languages
:
Java
# .NET/.NET Core components
# [3000, 4000) for C#/.NET only
...
...
@@ -258,6 +261,7 @@ Component-Server-Mappings:
h2-jdbc-driver
:
H2
mysql-connector-java
:
Mysql
Jedis
:
Redis
Redisson
:
Redis
StackExchange.Redis
:
Redis
SqlClient
:
SqlServer
Npgsql
:
PostgreSQL
...
...
oap-server/server-starter/src/main/resources/component-libraries.yml
浏览文件 @
43b216aa
...
...
@@ -195,6 +195,9 @@ Canal:
Gson
:
id
:
55
languages
:
Java
Redisson
:
id
:
56
languages
:
Java
# .NET/.NET Core components
...
...
@@ -280,6 +283,7 @@ Component-Server-Mappings:
mysql-connector-java
:
Mysql
Jedis
:
Redis
StackExchange.Redis
:
Redis
Redisson
:
Redis
SqlClient
:
SqlServer
Npgsql
:
PostgreSQL
MySqlConnector
:
Mysql
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录