Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
085f9b69
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / 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,发现更多精彩内容 >>
提交
085f9b69
编写于
4月 17, 2017
作者:
B
baiyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support plugin for MongoDB
上级
bd465ad9
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
458 addition
and
0 deletion
+458
-0
skywalking-sniffer/skywalking-agent/pom.xml
skywalking-sniffer/skywalking-agent/pom.xml
+5
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/pom.xml
...king-sniffer/skywalking-sdk-plugin/mongodb-plugin/pom.xml
+52
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBMethodInterceptor.java
...e/skywalking/plugin/mongodb/MongoDBMethodInterceptor.java
+139
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBReadBindingInterceptor.java
...walking/plugin/mongodb/MongoDBReadBindingInterceptor.java
+46
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBWriteBindingInterceptor.java
...alking/plugin/mongodb/MongoDBWriteBindingInterceptor.java
+46
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/OperationInfo.java
...va/com/a/eye/skywalking/plugin/mongodb/OperationInfo.java
+51
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/ReadMethod.java
.../java/com/a/eye/skywalking/plugin/mongodb/ReadMethod.java
+22
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/WriteMethod.java
...java/com/a/eye/skywalking/plugin/mongodb/WriteMethod.java
+23
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/define/MongoDBInstrumentation.java
...walking/plugin/mongodb/define/MongoDBInstrumentation.java
+72
-0
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/resources/skywalking-plugin.def
...n/mongodb-plugin/src/main/resources/skywalking-plugin.def
+1
-0
skywalking-sniffer/skywalking-sdk-plugin/pom.xml
skywalking-sniffer/skywalking-sdk-plugin/pom.xml
+1
-0
未找到文件。
skywalking-sniffer/skywalking-agent/pom.xml
浏览文件 @
085f9b69
...
...
@@ -55,6 +55,11 @@
<artifactId>
motan-plugin
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
com.a.eye
</groupId>
<artifactId>
skywalking-mongodb-plugin
</artifactId>
<version>
${project.version}
</version>
</dependency>
<!-- activation -->
<dependency>
...
...
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/pom.xml
0 → 100644
浏览文件 @
085f9b69
<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>
<artifactId>
skywalking-sdk-plugin
</artifactId>
<groupId>
com.a.eye
</groupId>
<version>
3.0.1-2017
</version>
</parent>
<artifactId>
skywalking-mongodb-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
mongodb-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.17
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mongodb
</groupId>
<artifactId>
mongo-java-driver
</artifactId>
<version>
3.4.2
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- 源码插件 -->
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-source-plugin
</artifactId>
<!-- 发布时自动将源码同时发布的配置 -->
<executions>
<execution>
<id>
attach-sources
</id>
<goals>
<goal>
jar
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBMethodInterceptor.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
import
java.util.List
;
import
com.a.eye.skywalking.api.context.ContextManager
;
import
com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.a.eye.skywalking.trace.Span
;
import
com.a.eye.skywalking.trace.tag.Tags
;
import
com.mongodb.bulk.DeleteRequest
;
import
com.mongodb.bulk.InsertRequest
;
import
com.mongodb.bulk.UpdateRequest
;
import
com.mongodb.bulk.WriteRequest
;
import
com.mongodb.operation.CountOperation
;
import
com.mongodb.operation.CreateCollectionOperation
;
import
com.mongodb.operation.CreateIndexesOperation
;
import
com.mongodb.operation.CreateViewOperation
;
import
com.mongodb.operation.DeleteOperation
;
import
com.mongodb.operation.DistinctOperation
;
import
com.mongodb.operation.FindAndDeleteOperation
;
import
com.mongodb.operation.FindAndReplaceOperation
;
import
com.mongodb.operation.FindAndUpdateOperation
;
import
com.mongodb.operation.FindOperation
;
import
com.mongodb.operation.GroupOperation
;
import
com.mongodb.operation.InsertOperation
;
import
com.mongodb.operation.ListCollectionsOperation
;
import
com.mongodb.operation.MapReduceToCollectionOperation
;
import
com.mongodb.operation.MapReduceWithInlineResultsOperation
;
import
com.mongodb.operation.MixedBulkWriteOperation
;
import
com.mongodb.operation.UpdateOperation
;
/**
* {@link MongoDBMethodInterceptor} intercept method of {@link com.mongodb.Mongo#execute(ReadOperation, ReadPreference)}
* or {@link com.mongodb.Mongo#execute(WriteOperation)}. record the mongoDB host, operation name and the key of the operation.
*
* @author baiyang
*/
public
class
MongoDBMethodInterceptor
implements
InstanceMethodsAroundInterceptor
{
/**
* The key name that MongoDB host in {@link EnhancedClassInstanceContext#context}.
*/
protected
static
final
String
MONGODB_HOST
=
"MONGODB_HOST"
;
/**
* The key name that MongoDB port in {@link EnhancedClassInstanceContext#context}.
*/
protected
static
final
String
MONGODB_PORT
=
"MONGODB_PORT"
;
private
static
final
String
MONGODB_COMPONENT
=
"MongoDB"
;
@Override
public
void
beforeMethod
(
final
EnhancedClassInstanceContext
context
,
final
InstanceMethodInvokeContext
interceptorContext
,
final
MethodInterceptResult
result
)
{
Object
[]
arguments
=
interceptorContext
.
allArguments
();
OperationInfo
operationInfo
=
this
.
getReadOperationInfo
(
arguments
[
0
]);
Span
span
=
ContextManager
.
createSpan
(
"MongoDB/"
+
operationInfo
.
getMethodName
());
Tags
.
COMPONENT
.
set
(
span
,
MONGODB_COMPONENT
);
Tags
.
DB_TYPE
.
set
(
span
,
MONGODB_COMPONENT
);
Tags
.
SPAN_KIND
.
set
(
span
,
Tags
.
SPAN_KIND_CLIENT
);
Tags
.
SPAN_LAYER
.
asDB
(
span
);
Tags
.
DB_STATEMENT
.
set
(
span
,
operationInfo
.
getMethodName
()
+
" "
+
operationInfo
.
getFilter
());
}
@Override
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
Span
span
=
ContextManager
.
activeSpan
();
Tags
.
PEER_HOST
.
set
(
span
,
context
.
get
(
MONGODB_HOST
,
String
.
class
));
Tags
.
PEER_PORT
.
set
(
span
,
(
Integer
)
context
.
get
(
MONGODB_PORT
));
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
void
handleMethodException
(
Throwable
t
,
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
)
{
ContextManager
.
activeSpan
().
log
(
t
);
}
/**
* Convert ReadOperation interface or WriteOperation interface to the implementation class.
* Get the method name and filter info.
*/
@SuppressWarnings
(
"rawtypes"
)
private
OperationInfo
getReadOperationInfo
(
Object
obj
)
{
if
(
obj
instanceof
CountOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
COUNT
.
getName
(),
((
CountOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
DistinctOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
DISTINCT
.
getName
(),
((
DistinctOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
FindOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
FIND
.
getName
(),
((
FindOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
GroupOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
GROUP
.
getName
(),
((
GroupOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
ListCollectionsOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
LIST_COLLECTIONS
.
getName
(),
((
ListCollectionsOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
MapReduceWithInlineResultsOperation
)
{
return
new
OperationInfo
(
ReadMethod
.
MAPREDUCE_WITHINLINE_RESULTS
.
getName
(),
((
ListCollectionsOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
DeleteOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
DELETE
.
getName
(),
((
DeleteOperation
)
obj
).
getDeleteRequests
().
toString
());
}
else
if
(
obj
instanceof
InsertOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
INSERT
.
getName
(),
((
InsertOperation
)
obj
).
getInsertRequests
().
toString
());
}
else
if
(
obj
instanceof
UpdateOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
UPDATE
.
getName
(),
((
UpdateOperation
)
obj
).
getUpdateRequests
().
toString
());
}
else
if
(
obj
instanceof
CreateCollectionOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
CREATECOLLECTION
.
getName
(),
((
CreateCollectionOperation
)
obj
).
getCollectionName
());
}
else
if
(
obj
instanceof
CreateIndexesOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
CREATEINDEXES
.
getName
(),
((
CreateIndexesOperation
)
obj
).
getIndexNames
().
toString
());
}
else
if
(
obj
instanceof
CreateViewOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
CREATEVIEW
.
getName
(),
((
CreateViewOperation
)
obj
).
getViewName
());
}
else
if
(
obj
instanceof
FindAndDeleteOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
FINDANDDELETE
.
getName
(),
((
FindAndDeleteOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
FindAndReplaceOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
FINDANDREPLACE
.
getName
(),
((
FindAndReplaceOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
FindAndUpdateOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
FINDANDUPDATE
.
getName
(),
((
FindAndUpdateOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
MapReduceToCollectionOperation
)
{
return
new
OperationInfo
(
WriteMethod
.
MAPREDUCETOCOLLECTION
.
getName
(),
((
MapReduceToCollectionOperation
)
obj
).
getFilter
().
toString
());
}
else
if
(
obj
instanceof
MixedBulkWriteOperation
)
{
List
<?
extends
WriteRequest
>
list
=
((
MixedBulkWriteOperation
)
obj
).
getWriteRequests
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
WriteRequest
request
:
list
)
{
if
(
request
instanceof
InsertRequest
)
{
sb
.
append
(((
InsertRequest
)
request
).
getDocument
().
toString
()).
append
(
","
);
}
else
if
(
request
instanceof
DeleteRequest
)
{
sb
.
append
(((
DeleteRequest
)
request
).
getFilter
()).
append
(
","
);
}
else
if
(
request
instanceof
UpdateRequest
)
{
sb
.
append
(((
UpdateRequest
)
request
).
getFilter
()).
append
(
","
);
}
}
return
new
OperationInfo
(
WriteMethod
.
MIXEDBULKWRITE
.
getName
(),
sb
.
toString
());
}
else
{
return
new
OperationInfo
(
WriteMethod
.
UNKNOW
.
getName
());
}
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBReadBindingInterceptor.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
import
com.a.eye.skywalking.api.context.ContextManager
;
import
com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.mongodb.ServerAddress
;
import
com.mongodb.binding.ReadBinding
;
/**
* {@link MongoDBReadBindingInterceptor} record the host and port information from {@link EnhancedClassInstanceContext#context},
*
* @author baiyang
*/
public
class
MongoDBReadBindingInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
}
/**
* Execute after {@link com.mongodb.Mongo#getReadBinding(ReadPreference)},
* record the host and port information
*/
@Override
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
ReadBinding
readBinding
=
(
ReadBinding
)
ret
;
ServerAddress
serverAddress
=
readBinding
.
getReadConnectionSource
().
getServerDescription
().
getAddress
();
String
host
=
serverAddress
.
getHost
();
Integer
port
=
serverAddress
.
getPort
();
context
.
set
(
MongoDBMethodInterceptor
.
MONGODB_HOST
,
host
);
context
.
set
(
MongoDBMethodInterceptor
.
MONGODB_PORT
,
port
);
return
ret
;
}
@Override
public
void
handleMethodException
(
Throwable
t
,
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
)
{
ContextManager
.
activeSpan
().
log
(
t
);
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/MongoDBWriteBindingInterceptor.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
import
com.a.eye.skywalking.api.context.ContextManager
;
import
com.a.eye.skywalking.api.plugin.interceptor.EnhancedClassInstanceContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.MethodInterceptResult
;
import
com.mongodb.ServerAddress
;
import
com.mongodb.binding.WriteBinding
;
/**
* {@link MongoDBWriteBindingInterceptor} record the host and port information from {@link EnhancedClassInstanceContext#context},
*
* @author baiyang
*/
public
class
MongoDBWriteBindingInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
MethodInterceptResult
result
)
{
}
/**
* Execute after {@link com.mongodb.Mongo#getWriteBinding()},
* record the host and port information
*/
@Override
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
WriteBinding
writeBinding
=
(
WriteBinding
)
ret
;
ServerAddress
serverAddress
=
writeBinding
.
getWriteConnectionSource
().
getServerDescription
().
getAddress
();
String
host
=
serverAddress
.
getHost
();
Integer
port
=
serverAddress
.
getPort
();
context
.
set
(
MongoDBMethodInterceptor
.
MONGODB_HOST
,
host
);
context
.
set
(
MongoDBMethodInterceptor
.
MONGODB_PORT
,
port
);
return
ret
;
}
@Override
public
void
handleMethodException
(
Throwable
t
,
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
)
{
ContextManager
.
activeSpan
().
log
(
t
);
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/OperationInfo.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
/**
* {@link OperationInfo} record the methodName and filter information
*
* @author baiyang
*/
public
class
OperationInfo
{
private
String
methodName
;
private
String
filter
;
public
OperationInfo
()
{
}
public
OperationInfo
(
String
methodName
)
{
super
();
this
.
methodName
=
methodName
;
this
.
filter
=
""
;
}
public
OperationInfo
(
String
methodName
,
String
filter
)
{
super
();
this
.
methodName
=
methodName
;
this
.
filter
=
filter
;
}
public
String
getMethodName
()
{
return
methodName
;
}
public
void
setMethodName
(
String
methodName
)
{
this
.
methodName
=
methodName
;
}
public
String
getFilter
()
{
return
filter
;
}
public
void
setFilter
(
String
filter
)
{
this
.
filter
=
filter
;
}
@Override
public
String
toString
()
{
return
"{methodName="
+
methodName
+
", filter="
+
filter
+
"}"
;
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/ReadMethod.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
/**
* {@link ReadMethod} mongoDB read method enum
*
* @author baiyang
*/
public
enum
ReadMethod
{
COUNT
(
"count"
),
DISTINCT
(
"distinct"
),
FIND
(
"find"
),
GROUP
(
"group"
),
LIST_COLLECTIONS
(
"listCollections"
),
MAPREDUCE_WITHINLINE_RESULTS
(
"mapReduceWithInlineResults"
);
private
String
name
;
private
ReadMethod
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/WriteMethod.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb
;
/**
* {@link WriteMethod} mongoDB write method enum
*
* @author baiyang
*/
public
enum
WriteMethod
{
DELETE
(
"delete"
),
INSERT
(
"insert"
),
UPDATE
(
"update"
),
CREATECOLLECTION
(
"createCollection"
),
CREATEINDEXES
(
"createIndexess"
),
CREATEVIEW
(
"createView"
),
FINDANDDELETE
(
"findAndDelete"
),
FINDANDREPLACE
(
"findAndReplace"
),
FINDANDUPDATE
(
"findAndUpdate"
),
MAPREDUCETOCOLLECTION
(
"mapReduceToCollection"
),
MIXEDBULKWRITE
(
"mixedBulkWrite"
),
UNKNOW
(
"unknow"
);
private
String
name
;
private
WriteMethod
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/java/com/a/eye/skywalking/plugin/mongodb/define/MongoDBInstrumentation.java
0 → 100644
浏览文件 @
085f9b69
package
com.a.eye.skywalking.plugin.mongodb.define
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
com.a.eye.skywalking.api.plugin.interceptor.ConstructorInterceptPoint
;
import
com.a.eye.skywalking.api.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
com.a.eye.skywalking.api.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
/**
* {@link MongoDBInstrumentation} presents that skywalking intercepts {@link com.mongodb.Mongo#execute(ReadOperation, ReadPreference)},{@link com.mongodb.Mongo#execute(WriteOperation)}
* by using {@link MongoDBMethodInterceptor}.
*
* @author baiyang
*/
public
class
MongoDBInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"com.mongodb.Mongo"
;
private
static
final
String
MONGDB_READ_BINDING_CLASS
=
"com.a.eye.skywalking.plugin.mongodb.MongoDBReadBindingInterceptor"
;
private
static
final
String
MONGDB_WRITE_BINDING_CLASS
=
"com.a.eye.skywalking.plugin.mongodb.MongoDBWriteBindingInterceptor"
;
private
static
final
String
MONGDB_METHOD_INTERCET_CLASS
=
"com.a.eye.skywalking.plugin.mongodb.MongoDBMethodInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
null
;
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"execute"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
MONGDB_METHOD_INTERCET_CLASS
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"getReadBinding"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
MONGDB_READ_BINDING_CLASS
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"getWriteBinding"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
MONGDB_WRITE_BINDING_CLASS
;
}
}
};
}
@Override
protected
String
enhanceClassName
()
{
return
ENHANCE_CLASS
;
}
}
skywalking-sniffer/skywalking-sdk-plugin/mongodb-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
085f9b69
com.a.eye.skywalking.plugin.mongodb.define.MongoDBInstrumentation
\ No newline at end of file
skywalking-sniffer/skywalking-sdk-plugin/pom.xml
浏览文件 @
085f9b69
...
...
@@ -17,6 +17,7 @@
<module>
jedis-2.x-plugin
</module>
<module>
tomcat-7.x-8.x-plugin
</module>
<module>
motan-plugin
</module>
<module>
mongodb-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录