Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
97b57786
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97b57786
编写于
1月 11, 2018
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Agent] Support jdbc4, jdbc3 and jdbc42 of postgresql driver
上级
36136911
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
3 deletion
+74
-3
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
...gin/jdbc/postgresql/define/ConnectionInstrumentation.java
+6
-3
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/MultiClassNameMatch.java
...pm/plugin/jdbc/postgresql/define/MultiClassNameMatch.java
+68
-0
未找到文件。
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
浏览文件 @
97b57786
...
...
@@ -29,7 +29,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
apache
.
skywalking
.
apm
.
plugin
.
jdbc
.
postgresql
.
define
.
MultiClassNameMatch
.
byMultiClassMatch
;
/**
* {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
...
...
@@ -49,8 +49,11 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
public
class
ConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
PREPARE_STATEMENT_METHOD_WITH_STRING_ARRAY_INTERCEPTOR_CLASS
=
"org.apache.skywalking.apm.plugin.jdbc.postgresql.JDBCPrepareStatementWithStringArrayInterceptor"
;
public
static
final
String
ENHANCE_CLASS
=
"org.postgresql.jdbc.PgConnection"
;
public
static
final
String
PG_CONNECTION_
ENHANCE_CLASS
=
"org.postgresql.jdbc.PgConnection"
;
public
static
final
String
STRING_ARRAY_ARGUMENT_TYPE
=
"java.lang.String[]"
;
public
static
final
String
PG_JDBC42_CONNECTION_ENHANCE_CLASS
=
"org.postgresql.jdbc42.Jdbc42Connection"
;
public
static
final
String
PG_JDBC3_CONNECTION_ENHANCE_CLASS
=
"org.postgresql.jdbc3g.Jdbc3gConnection"
;
public
static
final
String
PG_JDBC4_CONNECTION_ENHANCE_CLASS
=
"org.postgresql.jdbc4.Jdbc4Connection"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
...
...
@@ -127,6 +130,6 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
by
Name
(
ENHANCE_CLASS
);
return
by
MultiClassMatch
(
PG_CONNECTION_ENHANCE_CLASS
,
PG_JDBC42_CONNECTION_ENHANCE_CLASS
,
PG_JDBC3_CONNECTION_ENHANCE_CLASS
,
PG_JDBC4_CONNECTION_
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/postgresql/define/MultiClassNameMatch.java
0 → 100644
浏览文件 @
97b57786
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.jdbc.postgresql.define
;
import
java.util.Arrays
;
import
java.util.List
;
import
net.bytebuddy.description.type.TypeDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.IndirectMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
/**
* Match class with a given set of classes.
*
* @author zhangxin
*/
public
class
MultiClassNameMatch
implements
IndirectMatch
{
private
List
<
String
>
matchClassNames
;
private
MultiClassNameMatch
(
String
[]
classNames
)
{
if
(
classNames
==
null
||
classNames
.
length
==
0
)
{
throw
new
IllegalArgumentException
(
"match class names is null"
);
}
this
.
matchClassNames
=
Arrays
.
asList
(
classNames
);
}
@Override
public
ElementMatcher
.
Junction
buildJunction
()
{
ElementMatcher
.
Junction
junction
=
null
;
for
(
String
name
:
matchClassNames
)
{
if
(
junction
==
null
)
{
junction
=
named
(
name
);
}
else
{
junction
=
junction
.
or
(
named
(
name
));
}
}
return
junction
;
}
@Override
public
boolean
isMatch
(
TypeDescription
typeDescription
)
{
return
matchClassNames
.
contains
(
typeDescription
.
getTypeName
());
}
public
static
ClassMatch
byMultiClassMatch
(
String
...
classNames
)
{
return
new
MultiClassNameMatch
(
classNames
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录