Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
04bb6673
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,发现更多精彩内容 >>
未验证
提交
04bb6673
编写于
7月 02, 2021
作者:
A
AngryMills
提交者:
GitHub
7月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support parameter collection for sqlserver (#7217)
上级
f32d3d07
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
155 addition
and
5 deletion
+155
-5
CHANGES.md
CHANGES.md
+1
-0
apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/Constants.java
...apache/skywalking/apm/plugin/mssql/commons/Constants.java
+4
-0
apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java
...l/commons/PreparedStatementExecuteMethodsInterceptor.java
+16
-0
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementIgnoredSetterInstrumentation.java
...define/PreparedStatementIgnoredSetterInstrumentation.java
+33
-0
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementNullSetterInstrumentation.java
...bc/define/PreparedStatementNullSetterInstrumentation.java
+33
-0
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementSetterInstrumentation.java
...l/jdbc/define/PreparedStatementSetterInstrumentation.java
+33
-0
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/resources/skywalking-plugin.def
...ssql-jdbc-plugin/src/main/resources/skywalking-plugin.def
+4
-1
test/plugin/scenarios/mssql-jdbc-scenario/bin/startup.sh
test/plugin/scenarios/mssql-jdbc-scenario/bin/startup.sh
+1
-1
test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml
...in/scenarios/mssql-jdbc-scenario/config/expectedData.yaml
+21
-2
test/plugin/scenarios/mssql-jdbc-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
...org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
+8
-1
test/plugin/scenarios/mssql-jdbc-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/controller/CaseController.java
...walking/apm/testcase/mssql/controller/CaseController.java
+1
-0
未找到文件。
CHANGES.md
浏览文件 @
04bb6673
...
...
@@ -23,6 +23,7 @@ Release Notes.
*
Add
`Neo4j-4.x`
plugin.
*
Correct
`profile.duration`
to
`profile.max_duration`
in the default
`agent.config`
file.
*
Fix the response time of gRPC.
*
Support parameter collection for SqlServer.
*
Add
`ShardingSphere-5.0.0-beta`
plugin.
*
Fix some method exception error.
...
...
apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/Constants.java
浏览文件 @
04bb6673
...
...
@@ -18,10 +18,14 @@
package
org.apache.skywalking.apm.plugin.mssql.commons
;
import
org.apache.skywalking.apm.agent.core.context.tag.StringTag
;
public
class
Constants
{
public
static
final
String
CREATE_CALLABLE_STATEMENT_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.mssql.commons.CreateCallableStatementInterceptor"
;
public
static
final
String
CREATE_PREPARED_STATEMENT_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.mssql.commons.CreatePreparedStatementInterceptor"
;
public
static
final
String
CREATE_STATEMENT_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.mssql.commons.CreateStatementInterceptor"
;
public
static
final
String
PREPARED_STATEMENT_EXECUTE_METHODS_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.mssql.commons.PreparedStatementExecuteMethodsInterceptor"
;
public
static
final
String
STATEMENT_EXECUTE_METHODS_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.mssql.commons.StatementExecuteMethodsInterceptor"
;
public
static
final
StringTag
SQL_PARAMETERS
=
new
StringTag
(
"db.sql.parameters"
);
}
apm-sniffer/apm-sdk-plugin/mssql-commons/src/main/java/org/apache/skywalking/apm/plugin/mssql/commons/PreparedStatementExecuteMethodsInterceptor.java
浏览文件 @
04bb6673
...
...
@@ -26,6 +26,8 @@ import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.plugin.jdbc.JDBCPluginConfig
;
import
org.apache.skywalking.apm.plugin.jdbc.PreparedStatementParameterBuilder
;
import
org.apache.skywalking.apm.plugin.jdbc.SqlBodyUtil
;
import
org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos
;
import
org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
...
...
@@ -47,6 +49,13 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
Tags
.
DB_INSTANCE
.
set
(
span
,
connectInfo
.
getDatabaseName
());
Tags
.
DB_STATEMENT
.
set
(
span
,
SqlBodyUtil
.
limitSqlBodySize
(
cacheObject
.
getSql
()));
span
.
setComponent
(
connectInfo
.
getComponent
());
if
(
JDBCPluginConfig
.
Plugin
.
JDBC
.
TRACE_SQL_PARAMETERS
)
{
final
Object
[]
parameters
=
cacheObject
.
getParameters
();
if
(
parameters
!=
null
&&
parameters
.
length
>
0
)
{
int
maxIndex
=
cacheObject
.
getMaxIndex
();
Constants
.
SQL_PARAMETERS
.
set
(
span
,
getParameterString
(
parameters
,
maxIndex
));
}
}
SpanLayer
.
asDB
(
span
);
}
}
...
...
@@ -73,4 +82,11 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
private
String
buildOperationName
(
ConnectionInfo
connectionInfo
,
String
methodName
,
String
statementName
)
{
return
connectionInfo
.
getDBType
()
+
"/JDBI/"
+
statementName
+
"/"
+
methodName
;
}
private
String
getParameterString
(
Object
[]
parameters
,
int
maxIndex
)
{
return
new
PreparedStatementParameterBuilder
()
.
setParameters
(
parameters
)
.
setMaxIndex
(
maxIndex
)
.
build
();
}
}
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementIgnoredSetterInstrumentation.java
0 → 100644
浏览文件 @
04bb6673
/*
* 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.mssql.jdbc.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.plugin.jdbc.PSSetterDefinitionOfJDBCInstrumentation
;
public
class
PreparedStatementIgnoredSetterInstrumentation
extends
PreparedStatementInstrumentation
{
@Override
public
final
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
PSSetterDefinitionOfJDBCInstrumentation
(
true
)
};
}
}
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementNullSetterInstrumentation.java
0 → 100644
浏览文件 @
04bb6673
/*
* 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.mssql.jdbc.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.plugin.jdbc.JDBCPreparedStatementNullSetterInstanceMethodsInterceptPoint
;
public
class
PreparedStatementNullSetterInstrumentation
extends
PreparedStatementInstrumentation
{
@Override
public
final
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
JDBCPreparedStatementNullSetterInstanceMethodsInterceptPoint
()
};
}
}
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jdbc/define/PreparedStatementSetterInstrumentation.java
0 → 100644
浏览文件 @
04bb6673
/*
* 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.mssql.jdbc.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.plugin.jdbc.PSSetterDefinitionOfJDBCInstrumentation
;
public
class
PreparedStatementSetterInstrumentation
extends
PreparedStatementInstrumentation
{
@Override
public
final
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
PSSetterDefinitionOfJDBCInstrumentation
(
false
)
};
}
}
apm-sniffer/apm-sdk-plugin/mssql-jdbc-plugin/src/main/resources/skywalking-plugin.def
浏览文件 @
04bb6673
...
...
@@ -18,3 +18,6 @@ mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.DriverInstrumentat
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.ConnectionInstrumentation
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.PreparedStatementInstrumentation
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.StatementInstrumentation
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.PreparedStatementSetterInstrumentation
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.PreparedStatementNullSetterInstrumentation
mssql-jdbc=org.apache.skywalking.apm.plugin.mssql.jdbc.define.PreparedStatementIgnoredSetterInstrumentation
\ No newline at end of file
test/plugin/scenarios/mssql-jdbc-scenario/bin/startup.sh
浏览文件 @
04bb6673
...
...
@@ -18,4 +18,4 @@
home
=
"
$(
cd
"
$(
dirname
$0
)
"
;
pwd
)
"
java
-jar
${
agent_opts
}
${
home
}
/../libs/mssql-jdbc-scenario.jar &
\ No newline at end of file
java
-jar
${
agent_opts
}
-Dskywalking
.plugin.jdbc.trace_sql_parameters
=
true
${
home
}
/../libs/mssql-jdbc-scenario.jar &
\ No newline at end of file
test/plugin/scenarios/mssql-jdbc-scenario/config/expectedData.yaml
浏览文件 @
04bb6673
...
...
@@ -46,6 +46,7 @@ segmentItems:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
{
key
:
db.statement
,
value
:
'
INSERT
INTO
test_007(id,
value)
VALUES(?,?)'
}
-
{
key
:
db.sql.parameters
,
value
:
'
[1,1]'
}
logs
:
[]
startTime
:
nq
0
endTime
:
nq
0
...
...
@@ -55,10 +56,28 @@ segmentItems:
componentId
:
104
peer
:
mssql-server:1433
skipAnalysis
:
'
false'
-
operationName
:
Mssql/JDBI/Statement/execute
-
operationName
:
Mssql/JDBI/
Prepared
Statement/execute
operationId
:
eq
0
parentSpanId
:
0
spanId
:
3
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
{
key
:
db.statement
,
value
:
'
SELECT
id,
value
FROM
test_007
WHERE
id=?'
}
-
{
key
:
db.sql.parameters
,
value
:
'
[1]'
}
logs
:
[]
startTime
:
nq
0
endTime
:
nq
0
isError
:
false
spanLayer
:
Database
spanType
:
Exit
componentId
:
104
peer
:
mssql-server:1433
skipAnalysis
:
'
false'
-
operationName
:
Mssql/JDBI/Statement/execute
operationId
:
eq
0
parentSpanId
:
0
spanId
:
4
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
...
...
@@ -75,7 +94,7 @@ segmentItems:
-
operationName
:
Mssql/JDBI/Connection/close
operationId
:
eq
0
parentSpanId
:
0
spanId
:
4
spanId
:
5
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
...
...
test/plugin/scenarios/mssql-jdbc-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
浏览文件 @
04bb6673
...
...
@@ -51,6 +51,13 @@ public class SQLExecutor implements AutoCloseable {
preparedStatement
.
close
();
}
public
void
queryData
(
String
sql
,
String
id
)
throws
SQLException
{
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
preparedStatement
.
setString
(
1
,
id
);
preparedStatement
.
execute
();
preparedStatement
.
close
();
}
public
void
dropTable
(
String
sql
)
throws
SQLException
{
executeStatement
(
sql
);
}
...
...
test/plugin/scenarios/mssql-jdbc-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/controller/CaseController.java
浏览文件 @
04bb6673
...
...
@@ -45,6 +45,7 @@ public class CaseController {
try
(
SQLExecutor
sqlExecute
=
new
SQLExecutor
())
{
sqlExecute
.
createTable
(
CREATE_TABLE_SQL
);
sqlExecute
.
insertData
(
INSERT_DATA_SQL
,
"1"
,
"1"
);
sqlExecute
.
queryData
(
QUERY_DATA_SQL
,
"1"
);
sqlExecute
.
dropTable
(
DROP_TABLE_SQL
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Failed to execute sql."
,
e
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录