Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
75d8dc6f
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75d8dc6f
编写于
12月 02, 2017
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change the weave type of postgresql plugin
上级
f3a1bf5d
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
381 addition
and
23 deletion
+381
-23
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/StatementEnhanceInfos.java
...walking/apm/plugin/jdbc/define/StatementEnhanceInfos.java
+1
-1
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
...plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
...plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
...ing/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
...plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
+1
-1
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
...in/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
+1
-1
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/CreateCallableStatementInterceptor.java
...n/jdbc/postgresql/CreateCallableStatementInterceptor.java
+54
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/CreatePreparedStatementInterceptor.java
...n/jdbc/postgresql/CreatePreparedStatementInterceptor.java
+54
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/CreateStatementInterceptor.java
...pm/plugin/jdbc/postgresql/CreateStatementInterceptor.java
+57
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/StatementExecuteMethodsInterceptor.java
...n/jdbc/postgresql/StatementExecuteMethodsInterceptor.java
+75
-0
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/AbstractJdbc2StatementInstrumentation.java
...tgresql/define/AbstractJdbc2StatementInstrumentation.java
+85
-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
+6
-6
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Constants.java
...ywalking/apm/plugin/jdbc/postgresql/define/Constants.java
+31
-0
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
+8
-7
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc4ConnectionInstrumentation.java
...dbc/postgresql/define/Jdbc4ConnectionInstrumentation.java
+4
-4
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
+1
-0
未找到文件。
apm-sniffer/apm-sdk-plugin/
mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql
/define/StatementEnhanceInfos.java
→
apm-sniffer/apm-sdk-plugin/
jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc
/define/StatementEnhanceInfos.java
浏览文件 @
75d8dc6f
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.jdbc.
mysql.
define
;
package
org.skywalking.apm.plugin.jdbc.define
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
...
...
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptor.java
浏览文件 @
75d8dc6f
...
...
@@ -22,7 +22,7 @@ import java.lang.reflect.Method;
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.
mysql.
define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
...
...
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptor.java
浏览文件 @
75d8dc6f
...
...
@@ -22,7 +22,7 @@ import java.lang.reflect.Method;
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.
mysql.
define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
...
...
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptor.java
浏览文件 @
75d8dc6f
...
...
@@ -22,7 +22,7 @@ import java.lang.reflect.Method;
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.
mysql.
define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
...
...
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptor.java
浏览文件 @
75d8dc6f
...
...
@@ -26,7 +26,7 @@ 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.
mysql.
define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
...
...
apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/mysql/StatementExecuteMethodsInterceptorTest.java
浏览文件 @
75d8dc6f
...
...
@@ -37,7 +37,7 @@ import org.skywalking.apm.agent.test.tools.SegmentStoragePoint;
import
org.skywalking.apm.agent.test.tools.SpanAssert
;
import
org.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.skywalking.apm.plugin.jdbc.
mysql.
define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/CreateCallableStatementInterceptor.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
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.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
* {@link CreateStatementInterceptor} intercepts the {@link org.postgresql.jdbc.PgConnection#prepareCall} method in
* {@link org.postgresql.jdbc.PgConnection}, {@link org.postgresql.jdbc.PgConnection} or {@link org.postgresql.jdbc3.Jdbc3Connection} class.
*
* @author zhangxin
*/
public
class
CreateCallableStatementInterceptor
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
(
ret
instanceof
EnhancedInstance
)
{
((
EnhancedInstance
)
ret
).
setSkyWalkingDynamicField
(
new
StatementEnhanceInfos
((
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
],
"CallableStatement"
));
}
return
ret
;
}
@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/CreatePreparedStatementInterceptor.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
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.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
* {@link CreatePreparedStatementInterceptor} intercepts the {@link org.postgresql.jdbc.PgConnection#prepareStatement} method in
* {@link org.postgresql.jdbc.PgConnection}, {@link org.postgresql.jdbc.PgConnection} or {@link org.postgresql.jdbc3.Jdbc3Connection} class.
*
* @author zhangxin
*/
public
class
CreatePreparedStatementInterceptor
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
(
ret
instanceof
EnhancedInstance
)
{
((
EnhancedInstance
)
ret
).
setSkyWalkingDynamicField
(
new
StatementEnhanceInfos
((
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
(
String
)
allArguments
[
0
],
"PreparedStatement"
));
}
return
ret
;
}
@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/CreateStatementInterceptor.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
org.postgresql.jdbc.PgConnection
;
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.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
* {@link CreateStatementInterceptor} intercepts the {@link PgConnection#createStatement} method in
* {@link org.postgresql.jdbc.PgConnection}, {@link org.postgresql.jdbc.PgConnection} or {@link org.postgresql.jdbc3.Jdbc3Connection} class.
*
* @author zhangxin
*/
public
class
CreateStatementInterceptor
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
(
ret
instanceof
EnhancedInstance
)
{
((
EnhancedInstance
)
ret
).
setSkyWalkingDynamicField
(
new
StatementEnhanceInfos
((
ConnectionInfo
)
objInst
.
getSkyWalkingDynamicField
(),
""
,
"CallableStatement"
));
}
return
ret
;
}
@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/StatementExecuteMethodsInterceptor.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
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.define.StatementEnhanceInfos
;
import
org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
* {@link StatementExecuteMethodsInterceptor} create the exit span when the client call the interceptor methods.
*
* @author zhangxin
*/
public
class
StatementExecuteMethodsInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
final
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
StatementEnhanceInfos
cacheObject
=
(
StatementEnhanceInfos
)
objInst
.
getSkyWalkingDynamicField
();
ConnectionInfo
connectInfo
=
cacheObject
.
getConnectionInfo
();
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
buildOperationName
(
connectInfo
,
method
.
getName
(),
cacheObject
.
getStatementName
()),
connectInfo
.
getDatabasePeer
());
Tags
.
DB_TYPE
.
set
(
span
,
"sql"
);
Tags
.
DB_INSTANCE
.
set
(
span
,
connectInfo
.
getDatabaseName
());
Tags
.
DB_STATEMENT
.
set
(
span
,
cacheObject
.
getSql
());
span
.
setComponent
(
connectInfo
.
getComponent
());
SpanLayer
.
asDB
(
span
);
}
@Override
public
final
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
StatementEnhanceInfos
cacheObject
=
(
StatementEnhanceInfos
)
objInst
.
getSkyWalkingDynamicField
();
if
(
cacheObject
.
getConnectionInfo
()
!=
null
)
{
ContextManager
.
stopSpan
();
}
return
ret
;
}
@Override
public
final
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
StatementEnhanceInfos
cacheObject
=
(
StatementEnhanceInfos
)
objInst
.
getSkyWalkingDynamicField
();
if
(
cacheObject
.
getConnectionInfo
()
!=
null
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
private
String
buildOperationName
(
ConnectionInfo
connectionInfo
,
String
methodName
,
String
statementName
)
{
return
connectionInfo
.
getDBType
()
+
"/JDBI/"
+
statementName
+
"/"
+
methodName
;
}
}
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/AbstractJdbc2StatementInstrumentation.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
;
/**
* {@link AbstractJdbc2StatementInstrumentation} intercept the following methods that the class which extend {@link
* org.postgresql.jdbc2.AbstractJdbc2Statement} by {@link org.skywalking.apm.plugin.jdbc.postgresql.StatementExecuteMethodsInterceptor}. <br/>
* 1. the <code>execute</code> with non parameter
* 2. the <code>execute</code> with one parameter
* 3. the <code>executeBatch</code>
* 4. the <code>executeQuery</code> with non parameter
* 5. the <code>executeQuery</code> with one parameter
* 6. the <code>executeUpdate</code> with non parameter
* 7. the <code>executeUpdate</code> with one parameter
* 8. the <code>addBatch</code> with non parameter
* 9. the <code>addBatch</code> with one parameter
*
* @author zhangxin
*/
public
class
AbstractJdbc2StatementInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"org.postgresql.jdbc2.AbstractJdbc2Statement"
;
private
static
final
String
INTERCEPTOR_CLASS
=
"org.skywalking.apm.plugin.jdbc.postgresql.StatementExecuteMethodsInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"execute"
).
and
(
takesArguments
(
0
))
.
or
(
named
(
"execute"
).
and
(
takesArguments
(
1
)))
.
or
(
named
(
"executeBatch"
))
.
or
(
named
(
"executeQuery"
).
and
(
takesArguments
(
0
)))
.
or
(
named
(
"executeQuery"
).
and
(
takesArguments
(
1
)))
.
or
(
named
(
"executeUpdate"
).
and
(
takesArguments
(
0
)))
.
or
(
named
(
"executeUpdate"
).
and
(
takesArguments
(
1
)))
.
or
(
named
(
"addBatch"
).
and
(
takesArguments
(
1
)))
.
or
(
named
(
"addBatch"
).
and
(
takesArguments
(
0
)));
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPTOR_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/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
浏览文件 @
75d8dc6f
...
...
@@ -31,15 +31,15 @@ import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMat
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
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_CALLABLE_STATEMENT_INTERCEPTOR_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_PREPARED_STATEMENT_INTERCEPTOR_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPTOR_CLASS
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
...
...
@@ -74,7 +74,7 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT
_CLASS
;
return
CREATE_PREPARED_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -100,7 +100,7 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT
_CLASS
;
return
CREATE_CALLABLE_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -113,7 +113,7 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
return
CREATE_STATEMENT_INTERCEPT
OR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Constants.java
0 → 100644
浏览文件 @
75d8dc6f
/*
* 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
;
/**
* Interceptor class name constant variable
*
* @author zhangxin
*/
public
class
Constants
{
public
static
final
String
CREATE_STATEMENT_INTERCEPTOR_CLASS
=
"org.skywalking.apm.plugin.jdbc.postgresql.CreateStatementInterceptor"
;
public
static
final
String
CREATE_PREPARED_STATEMENT_INTERCEPTOR_CLASS
=
"org.skywalking.apm.plugin.jdbc.postgresql.CreatePreparedStatementInterceptor"
;
public
static
final
String
CREATE_CALLABLE_STATEMENT_INTERCEPTOR_CLASS
=
"org.skywalking.apm.plugin.jdbc.postgresql.CreateCallableStatementInterceptor"
;
}
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
浏览文件 @
75d8dc6f
...
...
@@ -30,15 +30,15 @@ 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
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_CALLABLE_STATEMENT_INTERCEPTOR_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_PREPARED_STATEMENT_INTERCEPTOR_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_STATEMENT_INTERCEPTOR_CLASS
;
/**
* {@link Jdbc3ConnectionInstrumentation} intercept the following methods that the class which extend {@link
...
...
@@ -69,7 +69,7 @@ public class Jdbc3ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT
_CLASS
;
return
CREATE_PREPARED_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -82,7 +82,7 @@ public class Jdbc3ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT
_CLASS
;
return
CREATE_CALLABLE_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -95,7 +95,7 @@ public class Jdbc3ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
}
@Override
public
String
getMethodsInterceptor
()
{
return
CREATE_STATEMENT_INTERCEPT_CLASS
;
return
CREATE_STATEMENT_INTERCEPT
OR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -104,7 +104,8 @@ public class Jdbc3ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
},
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
));
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
()
{
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc4ConnectionInstrumentation.java
浏览文件 @
75d8dc6f
...
...
@@ -32,13 +32,13 @@ 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
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_CALLABLE_STATEMENT_INTERCEPTOR_CLASS
;
import
static
org
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
Constants
.
CREATE_PREPARED_STATEMENT_INTERCEPTOR_CLASS
;
/**
* {@link Jdbc4ConnectionInstrumentation} intercept the following methods that the class which extend {@link
...
...
@@ -69,7 +69,7 @@ public class Jdbc4ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_STATEMENT_INTERCEPT
_CLASS
;
return
CREATE_PREPARED_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
@@ -82,7 +82,7 @@ public class Jdbc4ConnectionInstrumentation extends ClassInstanceMethodsEnhanceP
}
@Override
public
String
getMethodsInterceptor
()
{
return
PREPARE_CALL_INTERCEPT
_CLASS
;
return
CREATE_CALLABLE_STATEMENT_INTERCEPTOR
_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
...
...
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def
浏览文件 @
75d8dc6f
...
...
@@ -2,3 +2,4 @@ postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.DriverInstrument
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.Jdbc3ConnectionInstrumentation
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.Jdbc4ConnectionInstrumentation
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.ConnectionInstrumentation
postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.AbstractJdbc2StatementInstrumentation
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录