Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
e8f6f380
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
e8f6f380
编写于
10月 21, 2017
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change the implementation of jdbc plugins
上级
f5d818e9
变更
51
隐藏空白更改
内联
并排
Showing
51 changed file
with
1563 addition
and
80 deletion
+1563
-80
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml
+75
-0
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java
.../apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java
+148
-0
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
...king/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
+4
-4
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/resources/skywalking-plugin.def
...in/h2-1.x-plugin/src/main/resources/skywalking-plugin.def
+2
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml
apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml
+69
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
...g/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
+75
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCDriverInterceptor.java
...org/skywalking/apm/plugin/jdbc/JDBCDriverInterceptor.java
+5
-7
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java
...kywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java
+56
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java
...king/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java
+56
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java
.../skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java
+55
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
...m/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
+0
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
...plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
...ing/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
.../apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
...apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
...plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
...lking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDriverInstrumentation.java
...apm/plugin/jdbc/define/AbstractDriverInstrumentation.java
+8
-11
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/Constants.java
...java/org/skywalking/apm/plugin/jdbc/define/Constants.java
+44
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java
...lking/apm/plugin/jdbc/trace/CallableStatementTracing.java
+7
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/ConnectionInfo.java
.../org/skywalking/apm/plugin/jdbc/trace/ConnectionInfo.java
+1
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java
...lking/apm/plugin/jdbc/trace/PreparedStatementTracing.java
+7
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWCallableStatement.java
...skywalking/apm/plugin/jdbc/trace/SWCallableStatement.java
+22
-2
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWPreparedStatement.java
...skywalking/apm/plugin/jdbc/trace/SWPreparedStatement.java
+22
-2
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWStatement.java
...ava/org/skywalking/apm/plugin/jdbc/trace/SWStatement.java
+19
-2
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/StatementTracing.java
...rg/skywalking/apm/plugin/jdbc/trace/StatementTracing.java
+7
-1
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
...org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
+0
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
...ava/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
+1
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
...g/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
+8
-8
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
...est/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
+4
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
...java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
+0
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
.../java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
+0
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
...g/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
+0
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
...g/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
+2
-2
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/resources/skywalking-plugin.def
...ugin/jdbc-plugin/src/main/resources/skywalking-plugin.def
+0
-4
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
+5
-17
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
...m/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
+123
-0
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
...g/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
+4
-3
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
...mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
+2
-0
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml
+75
-0
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
...jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
+67
-0
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
.../plugin/jdbc/oracle/define/ConnectionInstrumentation.java
+158
-0
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/DriverInstrumentation.java
.../apm/plugin/jdbc/oracle/define/DriverInstrumentation.java
+5
-4
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
...acle-10.x-plugin/src/main/resources/skywalking-plugin.def
+2
-0
apm-sniffer/apm-sdk-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/pom.xml
+5
-1
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml
+75
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/JDBCPrepareStatementWithStringArrayInterceptor.java
...resql/JDBCPrepareStatementWithStringArrayInterceptor.java
+65
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
...gin/jdbc/postgresql/define/ConnectionInstrumentation.java
+142
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/DriverInstrumentation.java
.../plugin/jdbc/postgresql/define/DriverInstrumentation.java
+5
-3
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
...dbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
+124
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def
...resql-8.x-plugin/src/main/resources/skywalking-plugin.def
+3
-0
未找到文件。
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml
0 → 100755
浏览文件 @
e8f6f380
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
-->
<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>
apm-sdk-plugin
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.3-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-h2-1.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
h2-1.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
1.4.192
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-jdbc-commons
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
</plugin>
<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>
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.h2.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CLOSE_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
COMMIT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
ROLLBACK_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
* org.h2.jdbc.JdbcConnection}. <br/>
*
* 1. Enhance <code>prepareStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 3. Enhance <code>prepareCall</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 4. Enhance <code>createStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 5. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*
* @author zhangxin
*/
public
class
ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
ENHANCE_CLASS
=
"org.h2.jdbc.JdbcConnection"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
1
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_CALL_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
CREATE_STATEMENT_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
COMMIT_METHOD_NAME
).
or
(
named
(
ROLLBACK_METHOD_NAME
)).
or
(
named
(
CLOSE_METHOD_NAME
)).
or
(
named
(
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/
jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2
Instrumentation.java
→
apm-sniffer/apm-sdk-plugin/
h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/Driver
Instrumentation.java
浏览文件 @
e8f6f380
...
...
@@ -16,19 +16,19 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.define
;
package
org.skywalking.apm.plugin.jdbc.
h2.
define
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link
H2
Instrumentation} presents that skywalking intercepts {@link org.h2.Driver}.
* {@link
Driver
Instrumentation} presents that skywalking intercepts {@link org.h2.Driver}.
*
* @author zhangxin
*/
public
class
H2Instrumentation
extends
AbstractDatabaseInstrumentation
{
public
class
DriverInstrumentation
extends
AbstractDriverInstrumentation
{
private
static
final
String
CLASS_OF_INTERCEPT_H2_DRIVER
=
"org.h2.Driver"
;
@Override
...
...
apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
e8f6f380
h2-1.x=org.skywalking.apm.plugin.jdbc.h2.define.DriverInstrumentation
h2-1.x=org.skywalking.apm.plugin.jdbc.h2.define.ConnectionInstrumentation
apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml
0 → 100755
浏览文件 @
e8f6f380
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
-->
<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>
apm-sdk-plugin
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.3-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-jdbc-commons
</artifactId>
<packaging>
jar
</packaging>
<name>
jdbc-commons
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
[2.0.14,6.0.6]
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
</plugin>
<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>
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.context.tag.Tags
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link ConnectionServiceMethodInterceptor} create an exit span when the client call the following methods in the class
* that extend {@link java.sql.Connection}.
* 1. close
* 2. rollback
* 3. releaseSavepoint
* 4. commit
* @author zhangxin
*/
public
class
ConnectionServiceMethodInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
final
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
ConnectionInfo
connectInfo
=
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
();
String
remotePeer
;
if
(!
StringUtil
.
isEmpty
(
connectInfo
.
getHosts
()))
{
remotePeer
=
connectInfo
.
getHosts
();
}
else
{
remotePeer
=
connectInfo
.
getHost
()
+
":"
+
connectInfo
.
getPort
();
}
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
connectInfo
.
getDBType
()
+
"/JDBI/Connection/"
+
method
.
getName
(),
remotePeer
);
Tags
.
DB_TYPE
.
set
(
span
,
"sql"
);
Tags
.
DB_INSTANCE
.
set
(
span
,
connectInfo
.
getDatabaseName
());
Tags
.
DB_STATEMENT
.
set
(
span
,
""
);
span
.
setComponent
(
connectInfo
.
getComponent
());
SpanLayer
.
asDB
(
span
);
}
@Override
public
final
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
final
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define
/JDBCDriverInterceptor.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc
/JDBCDriverInterceptor.java
浏览文件 @
e8f6f380
...
...
@@ -16,19 +16,18 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
.define
;
package
org.skywalking.apm.plugin.jdbc
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.util.Properties
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.
SWConnection
;
import
org.skywalking.apm.plugin.jdbc.
connectionurl.parser.URLParser
;
/**
* {@link JDBCDriverInterceptor}
return {@link SWConnection} when {@link java.sql.Driver} to create connection,
* instead of the {@link Connection} instance.
* {@link JDBCDriverInterceptor}
set <code>ConnectionInfo</code> to {@link Connection} object when {@link
*
java.sql.Driver} to create connection,
instead of the {@link Connection} instance.
*
* @author zhangxin
*/
...
...
@@ -42,8 +41,7 @@ public class JDBCDriverInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
if
(
ret
!=
null
)
{
return
new
SWConnection
((
String
)
allArguments
[
0
],
(
Properties
)
allArguments
[
1
],
(
Connection
)
ret
);
((
EnhancedInstance
)
ret
).
setSkyWalkingDynamicField
(
URLParser
.
parser
((
String
)
allArguments
[
0
]));
}
return
ret
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
import
java.lang.reflect.Method
;
import
java.sql.CallableStatement
;
import
java.sql.Connection
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWCallableStatement
;
/**
* {@link JDBCPrepareCallInterceptor} return {@link SWCallableStatement} instance that wrapper the real CallStatement
* instance when the client call <code>prepareCall</code> method.
*
* @author zhangxin
*/
public
class
JDBCPrepareCallInterceptor
implements
InstanceMethodsAroundInterceptor
{
@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
{
if
(
objInst
.
getSkyWalkingDynamicField
()
==
null
)
{
return
ret
;
}
return
new
SWCallableStatement
((
Connection
)
objInst
,
(
CallableStatement
)
ret
,
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
]);
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement
;
/**
* {@link JDBCPrepareStatementInterceptor} return {@link SWPreparedStatement} instance that wrapper the real
* PreparedStatement instance when the client call <code>prepareStatement</code> method.
*
* @author zhangxin
*/
public
class
JDBCPrepareStatementInterceptor
implements
InstanceMethodsAroundInterceptor
{
@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
{
if
(
objInst
.
getSkyWalkingDynamicField
()
==
null
)
{
return
ret
;
}
return
new
SWPreparedStatement
((
Connection
)
objInst
,
(
PreparedStatement
)
ret
,
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
]);
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWStatement
;
/**
* {@link JDBCStatementInterceptor} return {@link SWStatement} instance that wrapper the real Statement instance when
* the client call <code>createStatement</code> method.
*
* @author zhangxin
*/
public
class
JDBCStatementInterceptor
implements
InstanceMethodsAroundInterceptor
{
@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
{
if
(
objInst
.
getSkyWalkingDynamicField
()
==
null
)
{
return
ret
;
}
return
new
SWStatement
((
Connection
)
objInst
,
(
java
.
sql
.
Statement
)
ret
,
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
());
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
浏览文件 @
e8f6f380
文件已移动
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
浏览文件 @
e8f6f380
...
...
@@ -18,7 +18,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
public
interface
ConnectionURLParser
{
/**
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
浏览文件 @
e8f6f380
...
...
@@ -19,7 +19,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
/**
* {@link H2URLParser} presents that skywalking how to parse the connection url of H2 database.
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
浏览文件 @
e8f6f380
...
...
@@ -19,7 +19,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
/**
* {@link MysqlURLParser} parse connection url of mysql.
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
浏览文件 @
e8f6f380
...
...
@@ -19,7 +19,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
/**
* {@link OracleURLParser} presents that how to parse oracle connection url.
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
浏览文件 @
e8f6f380
...
...
@@ -19,7 +19,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
/**
* {@link PostgreSQLURLParser} parse connection url of mysql.
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
浏览文件 @
e8f6f380
...
...
@@ -18,7 +18,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
/**
* {@link URLParser#parser(String)} support parse the connection url, such as Mysql, Oracle, H2 Database. But there are
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDatabase
Instrumentation.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDriver
Instrumentation.java
浏览文件 @
e8f6f380
...
...
@@ -23,29 +23,26 @@ import net.bytebuddy.matcher.ElementMatcher;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.plugin.jdbc.
SWConnection
;
import
org.skywalking.apm.plugin.jdbc.
JDBCDriverInterceptor
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
/**
* JDBC plugin using {@link JDBCDriverInterceptor} to intercept all the class that it has extend {@link
* java.sql.Driver#connect(String, java.util.Properties)}, and change the return object to {@link
* SWConnection}, All the method of {@link SWConnection}
* is delegate to the real JDBC Driver Connection object.
* JDBC plugin using {@link JDBCDriverInterceptor} to intercept the <code>connect</code> method of all driver class.
*
* @author zhangxin
*/
public
abstract
class
AbstractD
atabase
Instrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
abstract
class
AbstractD
river
Instrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.JDBCDriverInterceptor"
;
private
static
final
String
DRIVER_
INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.JDBCDriverInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
n
ull
;
protected
final
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
n
ew
ConstructorInterceptPoint
[
0
]
;
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
protected
final
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
...
...
@@ -55,7 +52,7 @@ public abstract class AbstractDatabaseInstrumentation extends ClassInstanceMetho
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPT_CLASS
;
return
DRIVER_
INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/Constants.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.define
;
public
class
Constants
{
public
static
final
String
CREATE_STATEMENT_INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor"
;
public
static
final
String
PREPARE_STATEMENT_INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor"
;
public
static
final
String
PREPARE_CALL_INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor"
;
public
static
final
String
SERVICE_METHOD_INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor"
;
public
static
final
String
PREPARE_STATEMENT_METHOD_NAME
=
"prepareStatement"
;
public
static
final
String
PREPARE_CALL_METHOD_NAME
=
"prepareCall"
;
public
static
final
String
CREATE_STATEMENT_METHOD_NAME
=
"createStatement"
;
public
static
final
String
COMMIT_METHOD_NAME
=
"commit"
;
public
static
final
String
ROLLBACK_METHOD_NAME
=
"rollback"
;
public
static
final
String
CLOSE_METHOD_NAME
=
"close"
;
public
static
final
String
RELEASE_SAVE_POINT_METHOD_NAME
=
"releaseSavepoint"
;
}
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/CallableStatementTracing.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/CallableStatementTracing.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.sql.SQLException
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
...
...
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link CallableStatementTracing} create an exit span when the client call the method in the class that extend {@link
* java.sql.CallableStatement}.
*
* @author zhangxin
*/
public
class
CallableStatementTracing
{
public
static
<
R
>
R
execute
(
java
.
sql
.
CallableStatement
realStatement
,
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/ConnectionInfo.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/ConnectionInfo.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
org.skywalking.apm.network.trace.component.OfficialComponent
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/PreparedStatementTracing.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/PreparedStatementTracing.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.sql.SQLException
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
...
...
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link PreparedStatementTracing} create an exit span when the client call the method in the class that extend {@link
* java.sql.PreparedStatement}.
*
* @author zhangxin
*/
public
class
PreparedStatementTracing
{
public
static
<
R
>
R
execute
(
java
.
sql
.
PreparedStatement
realStatement
,
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/SWCallableStatement.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/SWCallableStatement.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.io.InputStream
;
import
java.io.Reader
;
...
...
@@ -42,13 +42,33 @@ import java.sql.Timestamp;
import
java.util.Calendar
;
import
java.util.Map
;
/**
* {@link SWCallableStatement} wrapper the {@link CallableStatement} created by client. and it will interceptor the
* following methods for trace.
* 1. {@link #execute()}
* 2. {@link #execute(String)}
* 3. {@link #execute(String, int[])}
* 4. {@link #execute(String, String[])}
* 5. {@link #execute(String, int)}
* 6. {@link #executeQuery()}
* 7. {@link #executeQuery(String)}
* 8. {@link #executeUpdate()}
* 9. {@link #executeUpdate(String)}
* 10. {@link #executeUpdate(String, int[])}
* 11. {@link #executeUpdate(String, String[])}
* 12. {@link #executeUpdate(String, int)}
* 13. {@link #addBatch()}
* 14. {@link #addBatch(String)} ()}
*
* @author zhangxin
*/
public
class
SWCallableStatement
implements
CallableStatement
{
private
Connection
realConnection
;
private
CallableStatement
realStatement
;
private
ConnectionInfo
connectInfo
;
private
String
sql
;
SWCallableStatement
(
Connection
realConnection
,
public
SWCallableStatement
(
Connection
realConnection
,
CallableStatement
realStatement
,
ConnectionInfo
connectInfo
,
String
sql
)
{
this
.
realConnection
=
realConnection
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/SWPreparedStatement.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/SWPreparedStatement.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.io.InputStream
;
import
java.io.Reader
;
...
...
@@ -41,13 +41,33 @@ import java.sql.Time;
import
java.sql.Timestamp
;
import
java.util.Calendar
;
/**
* {@link SWPreparedStatement} wrapper the {@link PreparedStatement} created by client. and it will interceptor the
* following methods for trace.
* 1. {@link #execute()}
* 2. {@link #execute(String)}
* 3. {@link #execute(String, int[])}
* 4. {@link #execute(String, String[])}
* 5. {@link #execute(String, int)}
* 6. {@link #executeQuery()}
* 7. {@link #executeQuery(String)}
* 8. {@link #executeUpdate()}
* 9. {@link #executeUpdate(String)}
* 10. {@link #executeUpdate(String, int[])}
* 11. {@link #executeUpdate(String, String[])}
* 12. {@link #executeUpdate(String, int)}
* 13. {@link #addBatch()}
* 14. {@link #addBatch(String)} ()}
*
* @author zhangxin
*/
public
class
SWPreparedStatement
implements
PreparedStatement
{
private
Connection
realConnection
;
private
PreparedStatement
realStatement
;
private
ConnectionInfo
connectInfo
;
private
String
sql
;
SWPreparedStatement
(
Connection
realConnection
,
public
SWPreparedStatement
(
Connection
realConnection
,
PreparedStatement
realStatement
,
ConnectionInfo
connectInfo
,
String
sql
)
{
this
.
realConnection
=
realConnection
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/SWStatement.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/SWStatement.java
浏览文件 @
e8f6f380
...
...
@@ -16,19 +16,36 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLWarning
;
/**
* {@link SWStatement} wrapper the {@link java.sql.Statement} created by client. and it will interceptor the
* following methods for trace.
* 1. {@link #execute(String)}
* 2. {@link #execute(String, int[])}
* 3. {@link #execute(String, String[])}
* 4. {@link #execute(String, int)}
* 5. {@link #executeQuery(String)}
* 6. {@link #executeUpdate(String)}
* 7. {@link #executeUpdate(String, int[])}
* 8. {@link #executeUpdate(String, String[])}
* 9. {@link #executeUpdate(String, int)}
* 10. {@link #addBatch(String)} ()}
*
* @author zhangxin
*/
public
class
SWStatement
implements
java
.
sql
.
Statement
{
private
Connection
realConnection
;
private
java
.
sql
.
Statement
realStatement
;
private
ConnectionInfo
connectInfo
;
SWStatement
(
Connection
realConnection
,
java
.
sql
.
Statement
realStatement
,
ConnectionInfo
connectInfo
)
{
public
SWStatement
(
Connection
realConnection
,
java
.
sql
.
Statement
realStatement
,
ConnectionInfo
connectInfo
)
{
this
.
realConnection
=
realConnection
;
this
.
realStatement
=
realStatement
;
this
.
connectInfo
=
connectInfo
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main/java/org/skywalking/apm/plugin/jdbc
/StatementTracing.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace
/StatementTracing.java
浏览文件 @
e8f6f380
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc
;
package
org.skywalking.apm.plugin.jdbc
.trace
;
import
java.sql.SQLException
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
...
...
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link PreparedStatementTracing} create an exit span when the client call the method in the class that extend {@link
* java.sql.Statement}.
*
* @author zhangxin
*/
public
class
StatementTracing
{
public
static
<
R
>
R
execute
(
java
.
sql
.
Statement
realStatement
,
ConnectionInfo
connectInfo
,
String
method
,
String
sql
,
Executable
<
R
>
exec
)
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
浏览文件 @
e8f6f380
文件已移动
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main
/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/test
/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
浏览文件 @
e8f6f380
...
...
@@ -23,6 +23,7 @@ import org.skywalking.apm.agent.core.context.ContextManager;
import
org.skywalking.apm.agent.core.context.tag.Tags
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.util.StringUtil
;
public
class
ConnectionTracing
{
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
浏览文件 @
e8f6f380
...
...
@@ -124,11 +124,11 @@ public class SWCallableStatementTest extends AbstractStatementTest {
@Test
public
void
testSetParam
()
throws
SQLException
,
MalformedURLException
{
CallableStatement
callableStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
or b = ? or c=? or d = ? or
e = ?"
+
"
or e = ? or f = ? or g = ? or h = ? or i = ? or j = ? or k = ? or l = ? or m = ? or n = ? or o = ? or
p = ? "
+
"
or r = ? or s = ? or t = ? or u = ? or v = ? or w = ? or x = ? or y = ? or z = ? or a1 = ? or a2 = ? or
a3 = ?"
+
"
or a4 = ? or a5 = ? or a6 = ? or a7 = ? or a8 = ? or a9 = ? or b1 = ? or b2 = ? or b3 = ? or b4 = ? or
b5 = ?"
+
"
or b6 = ? or b7 = ? or b8 = ? or b9 = ? or c1 = ? or c2 = ? or
c3 = ?"
);
CallableStatement
callableStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
OR b = ? OR c=? OR d = ? OR
e = ?"
+
"
OR e = ? OR f = ? OR g = ? OR h = ? OR i = ? OR j = ? OR k = ? OR l = ? OR m = ? OR n = ? OR o = ? OR
p = ? "
+
"
OR r = ? OR s = ? OR t = ? OR u = ? OR v = ? OR w = ? OR x = ? OR y = ? OR z = ? OR a1 = ? OR a2 = ? OR
a3 = ?"
+
"
OR a4 = ? OR a5 = ? OR a6 = ? OR a7 = ? OR a8 = ? OR a9 = ? OR b1 = ? OR b2 = ? OR b3 = ? OR b4 = ? OR
b5 = ?"
+
"
OR b6 = ? OR b7 = ? OR b8 = ? OR b9 = ? OR c1 = ? OR c2 = ? OR
c3 = ?"
);
callableStatement
.
clearParameters
();
callableStatement
.
setAsciiStream
(
1
,
inputStream
);
callableStatement
.
setAsciiStream
(
2
,
inputStream
,
10
);
...
...
@@ -666,7 +666,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
@Test
public
void
testQueryWithMultiHost
()
throws
SQLException
{
CallableStatement
preparedStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
or b = ? or c=? or
d = ?"
,
1
,
1
);
CallableStatement
preparedStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
OR b = ? OR c=? OR
d = ?"
,
1
,
1
);
preparedStatement
.
setAsciiStream
(
1
,
inputStream
);
preparedStatement
.
setAsciiStream
(
2
,
inputStream
,
10
);
preparedStatement
.
setAsciiStream
(
3
,
inputStream
,
1000000L
);
...
...
@@ -683,7 +683,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
public
void
testMultiHostWithException
()
throws
SQLException
{
when
(
mysqlCallableStatement
.
executeQuery
()).
thenThrow
(
new
SQLException
());
try
{
CallableStatement
preparedStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
or b = ? or c=? or d = ? or
e=?"
);
CallableStatement
preparedStatement
=
multiHostConnection
.
prepareCall
(
"SELECT * FROM test WHERE a = ?
OR b = ? OR c=? OR d = ? OR
e=?"
);
preparedStatement
.
setBigDecimal
(
1
,
new
BigDecimal
(
10000
));
preparedStatement
.
setBlob
(
2
,
inputStream
);
preparedStatement
.
setBlob
(
3
,
inputStream
,
1000000L
);
...
...
@@ -705,7 +705,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
TraceSegment
traceSegment
=
segmentStorage
.
getTraceSegments
().
get
(
0
);
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
traceSegment
);
assertThat
(
spans
.
size
(),
is
(
1
));
assertDBSpan
(
spans
.
get
(
0
),
"Mysql/JDBI/CallableStatement/executeQuery"
,
"SELECT * FROM test WHERE a = ?
or b = ? or c=? or d = ? or
e=?"
);
assertDBSpan
(
spans
.
get
(
0
),
"Mysql/JDBI/CallableStatement/executeQuery"
,
"SELECT * FROM test WHERE a = ?
OR b = ? OR c=? OR d = ? OR
e=?"
);
List
<
LogDataEntity
>
logs
=
SpanHelper
.
getLogs
(
spans
.
get
(
0
));
Assert
.
assertThat
(
logs
.
size
(),
is
(
1
));
assertDBSpanLog
(
logs
.
get
(
0
));
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin/src/main
/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons/src/test
/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
100755 → 100644
浏览文件 @
e8f6f380
...
...
@@ -37,6 +37,10 @@ import java.util.Map;
import
java.util.Properties
;
import
java.util.concurrent.Executor
;
import
org.skywalking.apm.plugin.jdbc.connectionurl.parser.URLParser
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWCallableStatement
;
import
org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement
;
import
org.skywalking.apm.plugin.jdbc.trace.SWStatement
;
public
class
SWConnection
implements
Connection
{
private
ConnectionInfo
connectInfo
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
浏览文件 @
e8f6f380
文件已移动
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
浏览文件 @
e8f6f380
文件已移动
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
浏览文件 @
e8f6f380
文件已移动
apm-sniffer/apm-sdk-plugin/jdbc-
plugin
/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
→
apm-sniffer/apm-sdk-plugin/jdbc-
commons
/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
浏览文件 @
e8f6f380
...
...
@@ -19,7 +19,7 @@
package
org.skywalking.apm.plugin.jdbc.connectionurl.parser
;
import
org.junit.Test
;
import
org.skywalking.apm.plugin.jdbc.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.
trace.
ConnectionInfo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
...
...
@@ -121,4 +121,4 @@ public class URLParserTest {
assertThat
(
connectionInfo
.
getHost
(),
is
(
"localhost"
));
assertThat
(
connectionInfo
.
getPort
(),
is
(
8084
));
}
}
\ No newline at end of file
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/resources/skywalking-plugin.def
已删除
100644 → 0
浏览文件 @
f5d818e9
jdbc=org.skywalking.apm.plugin.jdbc.define.H2Instrumentation
jdbc=org.skywalking.apm.plugin.jdbc.define.MysqlInstrumentation
jdbc=org.skywalking.apm.plugin.jdbc.define.OracleInstrumentation
jdbc=org.skywalking.apm.plugin.jdbc.define.PostgreSQLInstrumentation
apm-sniffer/apm-sdk-plugin/
jdbc
-plugin/pom.xml
→
apm-sniffer/apm-sdk-plugin/
mysql-2.x
-plugin/pom.xml
浏览文件 @
e8f6f380
...
...
@@ -25,10 +25,10 @@
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-
jdbc
-plugin
</artifactId>
<artifactId>
apm-
mysql-2.x
-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
jdbc
-plugin
</name>
<name>
mysql-2.x
-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
...
...
@@ -42,18 +42,6 @@
<version>
5.1.36
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.oracle
</groupId>
<artifactId>
ojdbc14
</artifactId>
<version>
10.2.0.4.0
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</artifactId>
<version>
1.4.192
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
...
...
@@ -61,9 +49,9 @@
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.
postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<version>
42.0.0
</version>
<groupId>
org.
skywalking
</groupId>
<artifactId>
apm-jdbc-commons
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
...
...
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.mysql.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CLOSE_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
COMMIT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
ROLLBACK_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
* com.mysql.jdbc.ConnectionImpl}. <br/>
*
* 1. Enhance <code>prepareStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 2. Enhance <code>prepareCall</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 3. Enhance <code>createStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 4. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*
* @author zhangxin
*/
public
class
ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
ENHANCE_CLASS
=
"com.mysql.jdbc.ConnectionImpl"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_CALL_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
CREATE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
2
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
COMMIT_METHOD_NAME
).
or
(
named
(
ROLLBACK_METHOD_NAME
)).
or
(
named
(
CLOSE_METHOD_NAME
)).
or
(
named
(
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/
jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/Mysql
Instrumentation.java
→
apm-sniffer/apm-sdk-plugin/
mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/Driver
Instrumentation.java
浏览文件 @
e8f6f380
...
...
@@ -16,18 +16,19 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.define
;
package
org.skywalking.apm.plugin.jdbc.
mysql.
define
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link
Mysql
Instrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
* {@link
Driver
Instrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
*
* @author zhangxin
*/
public
class
MysqlInstrumentation
extends
AbstractDatabase
Instrumentation
{
public
class
DriverInstrumentation
extends
AbstractDriver
Instrumentation
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
"com.mysql.jdbc.Driver"
);
...
...
apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
e8f6f380
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml
0 → 100755
浏览文件 @
e8f6f380
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
-->
<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>
apm-sdk-plugin
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.3-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-oracle-10.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
oracle-10.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.oracle
</groupId>
<artifactId>
ojdbc14
</artifactId>
<version>
10.2.0.4.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-jdbc-commons
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
</plugin>
<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>
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
oracle.jdbc.driver
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement
;
/**
* {@link JDBCPrepareStatementWithArrayInterceptor} return {@link SWPreparedStatement} instance that wrapper the real
* preparedStatement instance when the client call <code>oracle.jdbc.driver.PhysicalConnection#prepareStatement(String,
* int[])</code> method or <code>oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])</code>
* method.
*
* @author zhangxin
*/
public
class
JDBCPrepareStatementWithArrayInterceptor
implements
InstanceMethodsAroundInterceptor
{
@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
{
/**
* To prevent the <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method from repeating
* interceptor, Because PGConnection call <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method when
* the second argument is empty.
*
* @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, int[])
* @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])
**/
String
sql
=
(
String
)
allArguments
[
0
];
if
(!
AutoKeyInfo
.
isInsertSqlStmt
(
sql
))
{
return
ret
;
}
return
new
SWPreparedStatement
((
Connection
)
objInst
,
(
PreparedStatement
)
ret
,
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
]);
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.oracle.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CLOSE_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
COMMIT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
ROLLBACK_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
* oracle.jdbc.driver.PhysicalConnection}. <br/>
*
* 1. Enhance <code>prepareStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 2. Enhance <code>prepareStatement</code> that the seconds argument type is <code>java.lang.String[]</code> by
* <code>oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor</code>
* 3. Enhance <code>prepareStatement</code> that the seconds argument type is <code>int[]</code> by
* <code>oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor</code>
* 4. Enhance <code>prepareCall</code> by
* <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 5. Enhance <code>createStatement</code>
* by <code>org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 6. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*
* @author zhangxin
*/
public
class
ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS
=
"oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"oracle.jdbc.driver.PhysicalConnection"
;
public
static
final
String
STRING_ARRAY_ARGUMENT_TYPE
=
"java.lang.String[]"
;
public
static
final
String
INT_ARRAY_ARGUMENT_TYPE
=
"int[]"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArgumentWithType
(
1
,
STRING_ARRAY_ARGUMENT_TYPE
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArgumentWithType
(
1
,
INT_ARRAY_ARGUMENT_TYPE
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_CALL_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
CREATE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
2
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
COMMIT_METHOD_NAME
).
or
(
named
(
ROLLBACK_METHOD_NAME
)).
or
(
named
(
CLOSE_METHOD_NAME
)).
or
(
named
(
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/
jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/Oracle
Instrumentation.java
→
apm-sniffer/apm-sdk-plugin/
oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/Driver
Instrumentation.java
浏览文件 @
e8f6f380
...
...
@@ -16,19 +16,20 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.define
;
package
org.skywalking.apm.plugin.jdbc.
oracle.
define
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link OracleInstrumentation} presents that skywalking intercepts the class <code>oracle.jdbc.OracleDriver
* </code>.
* {@link DriverInstrumentation} presents that skywalking intercepts {@link oracle.jdbc.driver.OracleDriver}.
*
* @author zhangxin
*/
public
class
OracleInstrumentation
extends
AbstractDatabaseInstrumentation
{
public
class
DriverInstrumentation
extends
AbstractDriverInstrumentation
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
"oracle.jdbc.driver.OracleDriver"
);
...
...
apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
e8f6f380
oracle-10.x=org.skywalking.apm.plugin.jdbc.oracle.define.DriverInstrumentation
oracle-10.x=org.skywalking.apm.plugin.jdbc.oracle.define.ConnectionInstrumentation
apm-sniffer/apm-sdk-plugin/pom.xml
浏览文件 @
e8f6f380
...
...
@@ -30,7 +30,7 @@
<artifactId>
apm-sdk-plugin
</artifactId>
<modules>
<module>
dubbo-plugin
</module>
<module>
jdbc-
plugin
</module>
<module>
jdbc-
commons
</module>
<module>
httpClient-4.x-plugin
</module>
<module>
jedis-2.x-plugin
</module>
<module>
tomcat-7.x-8.x-plugin
</module>
...
...
@@ -48,6 +48,10 @@
<module>
sharding-jdbc-1.5.x-plugin
</module>
<module>
xmemcached-2.x-plugin
</module>
<module>
grpc-1.x-plugin
</module>
<module>
mysql-2.x-plugin
</module>
<module>
h2-1.x-plugin
</module>
<module>
postgresql-8.x-plugin
</module>
<module>
oracle-10.x-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml
0 → 100755
浏览文件 @
e8f6f380
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
-->
<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>
apm-sdk-plugin
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.3-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-postgresql-8.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
postgresql-8.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
org.postgresql
</groupId>
<artifactId>
postgresql
</artifactId>
<version>
42.0.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-jdbc-commons
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-deploy-plugin
</artifactId>
</plugin>
<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>
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/JDBCPrepareStatementWithStringArrayInterceptor.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.postgresql
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement
;
/**
* {@link JDBCPrepareStatementWithStringArrayInterceptor} return {@link SWPreparedStatement} instance that wrapper the
* real preparedStatement instance when the client call <code>org.postgresql.jdbc.PgConnection#prepareStatement(String,
* String[]) </code> method. method.
*
* @author zhangxin
*/
public
class
JDBCPrepareStatementWithStringArrayInterceptor
implements
InstanceMethodsAroundInterceptor
{
@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
{
/**
* To prevent the <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method from repeating
* interceptor, Because PGConnection call <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method when
* the second argument is empty.
*
* @see org.postgresql.jdbc.PgConnection#prepareStatement(String, String[])
**/
String
[]
columnNames
=
(
String
[])
allArguments
[
1
];
if
(
columnNames
!=
null
&&
columnNames
.
length
==
0
)
{
return
ret
;
}
return
new
SWPreparedStatement
((
Connection
)
objInst
,
(
PreparedStatement
)
ret
,
(
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
]);
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.postgresql.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CLOSE_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
COMMIT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
ROLLBACK_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
* org.postgresql.jdbc.PgConnection}. <br/>
*
* 1. Enhance <code>prepareStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 2. Enhance <code>prepareStatement</code> that the seconds argument type is <code>java.lang.String[]</code> by
* <code>org.skywalking.apm.plugin.jdbc.postgresql.JDBCPrepareStatementWithStringArrayInterceptor</code>
* 3. Enhance <code>prepareCall</code> by
* <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 4. Enhance <code>createStatement</code>
* by <code>org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 5. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*
* @author zhangxin
*/
public
class
ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
PREPARE_STATEMENT_METHOD_WITH_STRING_ARRAY_INTERCEPTOR_CLASS
=
"org.skywalking.apm.plugin.jdbc.postgresql.JDBCPrepareStatementWithStringArrayInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"org.postgresql.jdbc.PgConnection"
;
public
static
final
String
STRING_ARRAY_ARGUMENT_TYPE
=
"java.lang.String[]"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArgumentWithType
(
1
,
STRING_ARRAY_ARGUMENT_TYPE
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_METHOD_WITH_STRING_ARRAY_INTERCEPTOR_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_CALL_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
CREATE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
COMMIT_METHOD_NAME
).
or
(
named
(
ROLLBACK_METHOD_NAME
)).
or
(
named
(
CLOSE_METHOD_NAME
)).
or
(
named
(
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/
jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/PostgreSQL
Instrumentation.java
→
apm-sniffer/apm-sdk-plugin/
postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Driver
Instrumentation.java
浏览文件 @
e8f6f380
...
...
@@ -16,18 +16,20 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.define
;
package
org.skywalking.apm.plugin.jdbc.
postgresql.
define
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link
PostgreSQL
Instrumentation} presents that skywalking intercepts {@link org.postgresql.Driver}.
* {@link
Driver
Instrumentation} presents that skywalking intercepts {@link org.postgresql.Driver}.
*
* @author zhangxin
*/
public
class
PostgreSQLInstrumentation
extends
AbstractDatabaseInstrumentation
{
public
class
DriverInstrumentation
extends
AbstractDriverInstrumentation
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
"org.postgresql.Driver"
);
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
0 → 100644
浏览文件 @
e8f6f380
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.postgresql.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CLOSE_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
COMMIT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
CREATE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_CALL_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
PREPARE_STATEMENT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
ROLLBACK_METHOD_NAME
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
define
.
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
* org.postgresql.jdbc.PgConnection}. <br/>
*
* 1. Enhance <code>prepareStatement</code> by <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 2. Enhance <code>prepareCall</code> by
* <code>org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 3. Enhance <code>createStatement</code>
* by <code>org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 4. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*
* @author zhangxin
*/
public
class
Jdbc3ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
ENHANCE_CLASS
=
"org.postgresql.jdbc3.Jdbc3Connection"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
PREPARE_CALL_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
CREATE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
COMMIT_METHOD_NAME
).
or
(
named
(
ROLLBACK_METHOD_NAME
)).
or
(
named
(
CLOSE_METHOD_NAME
)).
or
(
named
(
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
e8f6f380
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.DriverInstrumentation
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.Jdbc3ConnectionInstrumentation
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.ConnectionInstrumentation
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录