Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
7220643c
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,发现更多精彩内容 >>
未验证
提交
7220643c
编写于
11月 16, 2020
作者:
Z
zifeihan
提交者:
GitHub
11月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the plugin for mssql-jtds 1.x plugin. (#5842)
* Add the plugin for mssql-jtds 1.x plugin.
上级
ef1363d9
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
1088 addition
and
2 deletion
+1088
-2
.github/workflows/plugins-test.1.yaml
.github/workflows/plugins-test.1.yaml
+1
-0
CHANGES.md
CHANGES.md
+1
-0
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
...walking/apm/network/trace/component/ComponentsDefine.java
+2
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/connectionurl/parser/MssqlJtdsURLParser.java
.../plugin/jdbc/connectionurl/parser/MssqlJtdsURLParser.java
+122
-0
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
...lking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
+3
-0
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/pom.xml
+52
-0
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/AbstractConnectionInstrumentation.java
...sql/jtds/v1/define/AbstractConnectionInstrumentation.java
+150
-0
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/ConnectionInstrumentation.java
...lugin/mssql/jtds/v1/define/ConnectionInstrumentation.java
+35
-0
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/DriverInstrumentation.java
...pm/plugin/mssql/jtds/v1/define/DriverInstrumentation.java
+36
-0
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/resources/skywalking-plugin.def
...-jtds-1.x-plugin/src/main/resources/skywalking-plugin.def
+18
-0
apm-sniffer/apm-sdk-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/pom.xml
+1
-0
docs/en/setup/service-agent/java-agent/Plugin-list.md
docs/en/setup/service-agent/java-agent/Plugin-list.md
+1
-0
docs/en/setup/service-agent/java-agent/Supported-list.md
docs/en/setup/service-agent/java-agent/Supported-list.md
+1
-0
oap-server/server-bootstrap/src/main/resources/component-libraries.yml
...rver-bootstrap/src/main/resources/component-libraries.yml
+6
-2
test/plugin/scenarios/mssql-jtds-scenario/bin/startup.sh
test/plugin/scenarios/mssql-jtds-scenario/bin/startup.sh
+21
-0
test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml
...in/scenarios/mssql-jtds-scenario/config/expectedData.yaml
+106
-0
test/plugin/scenarios/mssql-jtds-scenario/configuration.yml
test/plugin/scenarios/mssql-jtds-scenario/configuration.yml
+32
-0
test/plugin/scenarios/mssql-jtds-scenario/pom.xml
test/plugin/scenarios/mssql-jtds-scenario/pom.xml
+120
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/assembly/assembly.xml
...narios/mssql-jtds-scenario/src/main/assembly/assembly.xml
+41
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/Application.java
...org/apache/skywalking/apm/testcase/mssql/Application.java
+34
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/MssqlConfig.java
...org/apache/skywalking/apm/testcase/mssql/MssqlConfig.java
+58
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
...org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
+88
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/controller/CaseController.java
...walking/apm/testcase/mssql/controller/CaseController.java
+65
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/application.yaml
...s/mssql-jtds-scenario/src/main/resources/application.yaml
+23
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/jdbc.properties
...os/mssql-jtds-scenario/src/main/resources/jdbc.properties
+18
-0
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/log4j2.xml
...enarios/mssql-jtds-scenario/src/main/resources/log4j2.xml
+30
-0
test/plugin/scenarios/mssql-jtds-scenario/support-version.list
...plugin/scenarios/mssql-jtds-scenario/support-version.list
+23
-0
未找到文件。
.github/workflows/plugins-test.1.yaml
浏览文件 @
7220643c
...
...
@@ -60,6 +60,7 @@ jobs:
-
mongodb-4.x-scenario
-
netty-socketio-scenario
-
postgresql-above9.4.1207-scenario
-
mssql-jtds-scenario
steps
:
-
uses
:
actions/checkout@v2
with
:
...
...
CHANGES.md
浏览文件 @
7220643c
...
...
@@ -18,6 +18,7 @@ Release Notes.
*
Add the plugin for async-http-client 2.x
*
Fix NPE in the nutz plugin.
*
Provide Apache Commons DBCP 2.x plugin.
*
Add the plugin for mssql-jtds 1.x plugin.
#### OAP-Backend
*
Add the
`@SuperDataset`
annotation for BrowserErrorLog.
...
...
apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
浏览文件 @
7220643c
...
...
@@ -188,4 +188,6 @@ public class ComponentsDefine {
public
static
final
OfficialComponent
ASYNC_HTTP_CLIENT
=
new
OfficialComponent
(
102
,
"AsyncHttpClient"
);
public
static
final
OfficialComponent
DBCP
=
new
OfficialComponent
(
103
,
"dbcp"
);
public
static
final
OfficialComponent
MSSQL_JDBC_DRIVER
=
new
OfficialComponent
(
104
,
"mssql-jdbc-driver"
);
}
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/connectionurl/parser/MssqlJtdsURLParser.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.connectionurl.parser
;
import
org.apache.skywalking.apm.agent.core.logging.api.ILog
;
import
org.apache.skywalking.apm.agent.core.logging.api.LogManager
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.apache.skywalking.apm.network.trace.component.OfficialComponent
;
import
org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo
;
/**
* {@link MssqlJtdsURLParser} parse connection url of mssql.
*/
public
class
MssqlJtdsURLParser
extends
AbstractURLParser
{
private
static
final
int
DEFAULT_PORT
=
1433
;
private
String
dbType
=
"Mssql"
;
private
OfficialComponent
component
=
ComponentsDefine
.
MSSQL_JDBC_DRIVER
;
private
static
ILog
LOGGER
=
LogManager
.
getLogger
(
MssqlJtdsURLParser
.
class
);
public
MssqlJtdsURLParser
(
String
url
)
{
super
(
url
);
}
public
MssqlJtdsURLParser
(
String
url
,
String
dbType
,
OfficialComponent
component
)
{
super
(
url
);
this
.
dbType
=
dbType
;
this
.
component
=
component
;
}
@Override
protected
URLLocation
fetchDatabaseHostsIndexRange
()
{
int
hostLabelStartIndex
=
url
.
indexOf
(
"//"
);
int
hostLabelEndIndex
=
url
.
indexOf
(
";"
,
hostLabelStartIndex
+
2
);
if
(
hostLabelEndIndex
==
-
1
)
{
hostLabelEndIndex
=
url
.
indexOf
(
"/"
,
hostLabelStartIndex
+
2
);
}
return
new
URLLocation
(
hostLabelStartIndex
+
2
,
hostLabelEndIndex
);
}
protected
String
fetchDatabaseNameFromURL
(
int
startSize
)
{
URLLocation
hostsLocation
=
fetchDatabaseNameIndexRange
(
startSize
);
if
(
hostsLocation
==
null
)
{
return
""
;
}
return
url
.
substring
(
hostsLocation
.
startIndex
(),
hostsLocation
.
endIndex
());
}
protected
URLLocation
fetchDatabaseNameIndexRange
(
int
startSize
)
{
int
databaseStartTag
=
url
.
indexOf
(
"/"
,
startSize
);
if
(
databaseStartTag
==
-
1
)
{
return
null
;
}
int
databaseEndTag
=
url
.
indexOf
(
";"
,
databaseStartTag
);
if
(
databaseEndTag
==
-
1
)
{
databaseEndTag
=
url
.
length
();
}
return
new
URLLocation
(
databaseStartTag
+
1
,
databaseEndTag
);
}
@Override
protected
URLLocation
fetchDatabaseNameIndexRange
()
{
int
databaseStartTag
=
url
.
lastIndexOf
(
"/"
);
int
databaseEndTag
=
url
.
indexOf
(
";"
,
databaseStartTag
);
if
(
databaseEndTag
==
-
1
)
{
databaseEndTag
=
url
.
length
();
}
return
new
URLLocation
(
databaseStartTag
+
1
,
databaseEndTag
);
}
@Override
public
ConnectionInfo
parse
()
{
try
{
URLLocation
location
=
fetchDatabaseHostsIndexRange
();
String
hosts
=
url
.
substring
(
location
.
startIndex
(),
location
.
endIndex
());
String
[]
hostSegment
=
hosts
.
split
(
","
);
if
(
hostSegment
.
length
>
1
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
host
:
hostSegment
)
{
if
(
host
.
split
(
":"
).
length
==
1
)
{
sb
.
append
(
host
).
append
(
":"
).
append
(
DEFAULT_PORT
).
append
(
","
);
}
else
{
sb
.
append
(
host
).
append
(
","
);
}
}
return
new
ConnectionInfo
(
component
,
dbType
,
sb
.
substring
(
0
,
sb
.
length
()
-
1
),
fetchDatabaseNameFromURL
());
}
else
{
String
[]
hostAndPort
=
hostSegment
[
0
].
split
(
":"
);
if
(
hostAndPort
.
length
!=
1
)
{
return
new
ConnectionInfo
(
component
,
dbType
,
hostAndPort
[
0
],
Integer
.
valueOf
(
hostAndPort
[
1
]),
fetchDatabaseNameFromURL
(
location
.
endIndex
())
);
}
else
{
return
new
ConnectionInfo
(
component
,
dbType
,
hostAndPort
[
0
],
DEFAULT_PORT
,
fetchDatabaseNameFromURL
(
location
.
endIndex
()));
}
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
,
"parse mssql connection info error, url:{}"
,
url
);
return
new
ConnectionInfo
(
component
,
dbType
,
url
,
"UNKNOWN"
);
}
}
}
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
浏览文件 @
7220643c
...
...
@@ -31,6 +31,7 @@ public class URLParser {
private
static
final
String
H2_JDBC_URL_PREFIX
=
"jdbc:h2"
;
private
static
final
String
POSTGRESQL_JDBC_URL_PREFIX
=
"jdbc:postgresql"
;
private
static
final
String
MARIADB_JDBC_URL_PREFIX
=
"jdbc:mariadb"
;
private
static
final
String
MSSQL_JTDS_URL_PREFIX
=
"jdbc:jtds:sqlserver:"
;
public
static
ConnectionInfo
parser
(
String
url
)
{
ConnectionURLParser
parser
=
null
;
...
...
@@ -45,6 +46,8 @@ public class URLParser {
parser
=
new
PostgreSQLURLParser
(
url
);
}
else
if
(
lowerCaseUrl
.
startsWith
(
MARIADB_JDBC_URL_PREFIX
))
{
parser
=
new
MariadbURLParser
(
url
);
}
else
if
(
lowerCaseUrl
.
startsWith
(
MSSQL_JTDS_URL_PREFIX
))
{
parser
=
new
MssqlJtdsURLParser
(
url
);
}
return
parser
.
parse
();
}
...
...
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/pom.xml
0 → 100644
浏览文件 @
7220643c
<!--
~ 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.
~
-->
<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.apache.skywalking
</groupId>
<version>
8.3.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-mssql-jtds-1.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
mssql-jtds-1.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<mssql-jtds.version>
1.2.6
</mssql-jtds.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
apm-jdbc-commons
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
net.sourceforge.jtds
</groupId>
<artifactId>
jtds
</artifactId>
<version>
${mssql-jtds.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/AbstractConnectionInstrumentation.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.jtds.v1.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.plugin.jdbc.define.Constants
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
/**
* {@link AbstractConnectionInstrumentation} define how to enhance the following methods that the class which extend
* {@link java.sql.Connection}.
* <p>
* 1. Enhance <code>prepareStatement</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
* 2. Enhance <code>prepareCall</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
* 3. Enhance <code>createStatement</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
* 4. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
*/
public
abstract
class
AbstractConnectionInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
1
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
3
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
PREPARE_STATEMENT_METHOD_NAME
).
and
(
takesArguments
(
4
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
PREPARE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
PREPARE_CALL_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
PREPARE_CALL_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
CREATE_STATEMENT_METHOD_NAME
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
CREATE_STATEMENT_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
Constants
.
COMMIT_METHOD_NAME
).
or
(
named
(
Constants
.
ROLLBACK_METHOD_NAME
))
.
or
(
named
(
Constants
.
CLOSE_METHOD_NAME
))
.
or
(
named
(
Constants
.
RELEASE_SAVE_POINT_METHOD_NAME
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
SERVICE_METHOD_INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
}
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/ConnectionInstrumentation.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.jtds.v1.define
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch
;
/**
* {@link ConnectionInstrumentation} presents that skywalking intercepts.
*/
public
class
ConnectionInstrumentation
extends
AbstractConnectionInstrumentation
{
public
static
final
String
ENHANCE_CONNECTION_JDBC2_CLASS
=
"net.sourceforge.jtds.jdbc.ConnectionJDBC2"
;
public
static
final
String
ENHANCE_JTDS_CONNECTION_CLASS
=
"net.sourceforge.jtds.jdbc.JtdsConnection"
;
@Override
protected
ClassMatch
enhanceClass
()
{
return
MultiClassNameMatch
.
byMultiClassMatch
(
ENHANCE_CONNECTION_JDBC2_CLASS
,
ENHANCE_JTDS_CONNECTION_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/mssql/jtds/v1/define/DriverInstrumentation.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.jtds.v1.define
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link DriverInstrumentation} presents that skywalking intercepts {@link net.sourceforge.jtds.jdbc.Driver}.
*/
public
class
DriverInstrumentation
extends
AbstractDriverInstrumentation
{
private
static
final
String
ENHANCE_CLASS
=
"net.sourceforge.jtds.jdbc.Driver"
;
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/mssql-jtds-1.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
7220643c
# 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.
mssql-jtds-1.x=org.apache.skywalking.apm.plugin.mssql.jtds.v1.define.DriverInstrumentation
mssql-jtds-1.x=org.apache.skywalking.apm.plugin.mssql.jtds.v1.define.ConnectionInstrumentation
apm-sniffer/apm-sdk-plugin/pom.xml
浏览文件 @
7220643c
...
...
@@ -104,6 +104,7 @@
<module>
httpclient-commons
</module>
<module>
asynchttpclient-2.x-plugin
</module>
<module>
dbcp-2.x-plugin
</module>
<module>
mssql-jtds-1.x-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
docs/en/setup/service-agent/java-agent/Plugin-list.md
浏览文件 @
7220643c
...
...
@@ -109,3 +109,4 @@
-
vertx-core-3.x
-
xxl-job-2.x
-
zookeeper-3.4.x
-
mssql-jtds-1.x
\ No newline at end of file
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
7220643c
...
...
@@ -39,6 +39,7 @@ metrics based on the tracing data.
*
PostgreSQL Driver 8.x, 9.x, 42.x
*
Mariadb Driver 2.x, 1.8
*
[
InfluxDB
](
https://github.com/influxdata/influxdb-java
)
2.5 -> 2.17
*
[
Mssql-Jtds
](
https://github.com/milesibastos/jTDS
)
1.x
*
RPC Frameworks
*
[
Dubbo
](
https://github.com/alibaba/dubbo
)
2.5.4 -> 2.6.0
*
[
Dubbox
](
https://github.com/dangdangdotcom/dubbox
)
2.8.4
...
...
oap-server/server-bootstrap/src/main/resources/component-libraries.yml
浏览文件 @
7220643c
...
...
@@ -341,6 +341,9 @@ AsyncHttpClient:
dbcp
:
id
:
103
languages
:
Java
mssql-jdbc-driver
:
id
:
104
languages
:
Java
# .NET/.NET Core components
# [3000, 4000) for C#/.NET only
...
...
@@ -361,7 +364,7 @@ StackExchange.Redis:
languages
:
C#
SqlServer
:
id
:
3006
languages
:
C#
languages
:
C#
,Java
Npgsql
:
id
:
3007
languages
:
C#
...
...
@@ -537,4 +540,5 @@ Component-Server-Mappings:
influxdb-java
:
InfluxDB
Predis
:
Redis
PyMysql
:
Mysql
spring-kafka-consumer
:
kafka-consumer
\ No newline at end of file
spring-kafka-consumer
:
kafka-consumer
mssql-jdbc-driver
:
SqlServer
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/bin/startup.sh
0 → 100644
浏览文件 @
7220643c
#!/bin/bash
#
# 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.
home
=
"
$(
cd
"
$(
dirname
$0
)
"
;
pwd
)
"
java
-jar
${
agent_opts
}
${
home
}
/../libs/mssql-jtds-scenario.jar &
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/config/expectedData.yaml
0 → 100644
浏览文件 @
7220643c
# 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.
segmentItems
:
-
serviceName
:
mssql-jtds-scenario
segmentSize
:
ge
2
segments
:
-
segmentId
:
not
null
spans
:
-
operationName
:
Mssql/JDBI/PreparedStatement/execute
operationId
:
eq
0
parentSpanId
:
0
spanId
:
1
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
key
:
db.statement
value
:
"
CREATE
TABLE
test_007(
\n
id
VARCHAR(1)
PRIMARY
KEY,
\n
value
VARCHAR(1)
\
\
NOT
NULL)"
logs
:
[]
startTime
:
nq
0
endTime
:
nq
0
isError
:
false
spanLayer
:
Database
spanType
:
Exit
componentId
:
104
peer
:
mssql-server:1433
skipAnalysis
:
'
false'
-
operationName
:
Mssql/JDBI/PreparedStatement/execute
operationId
:
eq
0
parentSpanId
:
0
spanId
:
2
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
{
key
:
db.statement
,
value
:
'
INSERT
INTO
test_007(id,
value)
VALUES(?,?)'
}
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
:
3
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
{
key
:
db.statement
,
value
:
DROP table test_007
}
logs
:
[]
startTime
:
nq
0
endTime
:
nq
0
isError
:
false
spanLayer
:
Database
spanType
:
Exit
componentId
:
104
peer
:
mssql-server:1433
skipAnalysis
:
'
false'
-
operationName
:
Mssql/JDBI/Connection/close
operationId
:
eq
0
parentSpanId
:
0
spanId
:
4
tags
:
-
{
key
:
db.type
,
value
:
sql
}
-
{
key
:
db.instance
,
value
:
tempdb
}
-
{
key
:
db.statement
,
value
:
'
'
}
logs
:
[]
startTime
:
nq
0
endTime
:
nq
0
isError
:
false
spanLayer
:
Database
spanType
:
Exit
componentId
:
104
peer
:
mssql-server:1433
skipAnalysis
:
'
false'
-
operationName
:
/mssql-jtds-scenario/case/mssql-jtds-scenario
operationId
:
eq
0
parentSpanId
:
-1
spanId
:
0
startTime
:
nq
0
endTime
:
nq
0
spanLayer
:
Http
isError
:
false
spanType
:
Entry
componentId
:
1
tags
:
-
{
key
:
url
,
value
:
'
http://localhost:8080/mssql-jtds-scenario/case/mssql-jtds-scenario'
}
-
{
key
:
http.method
,
value
:
GET
}
logs
:
[]
skipAnalysis
:
'
false'
test/plugin/scenarios/mssql-jtds-scenario/configuration.yml
0 → 100644
浏览文件 @
7220643c
# 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.
type
:
jvm
entryService
:
http://localhost:8080/mssql-jtds-scenario/case/mssql-jtds-scenario
healthCheck
:
http://localhost:8080/mssql-jtds-scenario/case/healthCheck
startScript
:
./bin/startup.sh
environment
:
depends_on
:
-
mssql-server
dependencies
:
mssql-server
:
image
:
microsoft/mssql-server-linux
hostname
:
mssql-server
expose
:
-
"
1433"
environment
:
-
SA_PASSWORD=yourStrong(!)Password
-
ACCEPT_EULA=Y
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/pom.xml
0 → 100644
浏览文件 @
7220643c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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"
>
<groupId>
org.apache.skywalking.apm.testcase
</groupId>
<artifactId>
mssql-jtds-scenario
</artifactId>
<version>
1.0.0
</version>
<packaging>
jar
</packaging>
<modelVersion>
4.0.0
</modelVersion>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<compiler.version>
1.8
</compiler.version>
<test.framework.version>
1.3.1
</test.framework.version>
<docker.image.version>
${test.framework.version}
</docker.image.version>
<spring-boot-version>
2.1.6.RELEASE
</spring-boot-version>
</properties>
<name>
skywalking-mssql-jtds-scenario
</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-dependencies
</artifactId>
<version>
${spring-boot-version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<exclusions>
<exclusion>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-logging
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-log4j2
</artifactId>
</dependency>
<dependency>
<groupId>
net.sourceforge.jtds
</groupId>
<artifactId>
jtds
</artifactId>
<version>
${test.framework.version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
mssql-jtds-scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
${compiler.version}
</source>
<target>
${compiler.version}
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<executions>
<execution>
<id>
assemble
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
src/main/assembly/assembly.xml
</descriptor>
</descriptors>
<outputDirectory>
./target/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/src/main/assembly/assembly.xml
0 → 100644
浏览文件 @
7220643c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<assembly
xmlns=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"
>
<formats>
<format>
zip
</format>
</formats>
<fileSets>
<fileSet>
<directory>
./bin
</directory>
<fileMode>
0775
</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>
${project.build.directory}/mssql-jtds-scenario.jar
</source>
<outputDirectory>
./libs
</outputDirectory>
<fileMode>
0775
</fileMode>
</file>
</files>
</assembly>
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/Application.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.testcase.mssql
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
try
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
catch
(
Exception
e
)
{
// Never do this
}
}
}
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/MssqlConfig.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.testcase.mssql
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
public
class
MssqlConfig
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
MssqlConfig
.
class
);
private
static
String
url
;
private
static
String
userName
;
private
static
String
password
;
static
{
InputStream
inputStream
=
MssqlConfig
.
class
.
getClassLoader
().
getResourceAsStream
(
"jdbc.properties"
);
Properties
properties
=
new
Properties
();
try
{
properties
.
load
(
inputStream
);
}
catch
(
IOException
e
)
{
LOGGER
.
error
(
"Failed to load config"
,
e
);
}
url
=
properties
.
getProperty
(
"mssql.url"
);
userName
=
properties
.
getProperty
(
"mssql.username"
);
password
=
properties
.
getProperty
(
"mssql.password"
);
}
public
static
String
getUrl
()
{
return
url
;
}
public
static
String
getUserName
()
{
return
userName
;
}
public
static
String
getPassword
()
{
return
password
;
}
}
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/SQLExecutor.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.testcase.mssql
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
public
class
SQLExecutor
implements
AutoCloseable
{
private
Connection
connection
;
public
SQLExecutor
()
throws
SQLException
{
try
{
Class
.
forName
(
"net.sourceforge.jtds.jdbc.Driver"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
connection
=
DriverManager
.
getConnection
(
MssqlConfig
.
getUrl
(),
MssqlConfig
.
getUserName
(),
MssqlConfig
.
getPassword
());
}
public
void
createTable
(
String
sql
)
throws
SQLException
{
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
preparedStatement
.
execute
();
preparedStatement
.
close
();
}
public
void
insertData
(
String
sql
,
String
id
,
String
value
)
throws
SQLException
{
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
preparedStatement
.
setString
(
1
,
id
);
preparedStatement
.
setString
(
2
,
value
);
preparedStatement
.
execute
();
preparedStatement
.
close
();
}
public
void
dropTable
(
String
sql
)
throws
SQLException
{
executeStatement
(
sql
);
}
public
void
createProcedure
(
String
sql
)
throws
SQLException
{
executeStatement
(
sql
);
}
public
void
dropProcedure
(
String
sql
)
throws
SQLException
{
executeStatement
(
sql
);
}
public
void
callProcedure
(
String
sql
,
String
id
)
throws
SQLException
{
PreparedStatement
preparedStatement
=
connection
.
prepareCall
(
sql
);
preparedStatement
.
setString
(
1
,
id
);
preparedStatement
.
execute
();
preparedStatement
.
close
();
}
public
void
executeStatement
(
String
sql
)
throws
SQLException
{
Statement
preparedStatement
=
connection
.
createStatement
();
preparedStatement
.
execute
(
sql
);
preparedStatement
.
close
();
}
public
void
closeConnection
()
throws
SQLException
{
if
(
this
.
connection
!=
null
)
{
this
.
connection
.
close
();
}
}
@Override
public
void
close
()
throws
Exception
{
closeConnection
();
}
}
test/plugin/scenarios/mssql-jtds-scenario/src/main/java/org/apache/skywalking/apm/testcase/mssql/controller/CaseController.java
0 → 100644
浏览文件 @
7220643c
/*
* 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.testcase.mssql.controller
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.skywalking.apm.testcase.mssql.SQLExecutor
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/case"
)
public
class
CaseController
{
private
static
final
Logger
LOGGER
=
LogManager
.
getLogger
(
CaseController
.
class
);
private
static
final
String
SUCCESS
=
"Success"
;
private
static
final
String
CREATE_TABLE_SQL
=
"CREATE TABLE test_007(\n"
+
"id VARCHAR(1) PRIMARY KEY, \n"
+
"value VARCHAR(1) NOT NULL)"
;
private
static
final
String
INSERT_DATA_SQL
=
"INSERT INTO test_007(id, value) VALUES(?,?)"
;
private
static
final
String
QUERY_DATA_SQL
=
"SELECT id, value FROM test_007 WHERE id=?"
;
private
static
final
String
DELETE_DATA_SQL
=
"DELETE FROM test_007 WHERE id=?"
;
private
static
final
String
DROP_TABLE_SQL
=
"DROP table test_007"
;
@RequestMapping
(
"/mssql-jtds-scenario"
)
@ResponseBody
public
String
testcase
()
throws
Exception
{
try
(
SQLExecutor
sqlExecute
=
new
SQLExecutor
())
{
sqlExecute
.
createTable
(
CREATE_TABLE_SQL
);
sqlExecute
.
insertData
(
INSERT_DATA_SQL
,
"1"
,
"1"
);
sqlExecute
.
dropTable
(
DROP_TABLE_SQL
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Failed to execute sql."
,
e
);
throw
e
;
}
return
SUCCESS
;
}
@RequestMapping
(
"/healthCheck"
)
@ResponseBody
public
String
healthCheck
()
throws
Exception
{
try
(
SQLExecutor
sqlExecutor
=
new
SQLExecutor
())
{
// ignore
}
return
SUCCESS
;
}
}
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/application.yaml
0 → 100644
浏览文件 @
7220643c
#
# 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.
#
#
server
:
port
:
8080
servlet
:
context-path
:
/mssql-jtds-scenario
logging
:
config
:
classpath:log4j2.xml
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/jdbc.properties
0 → 100644
浏览文件 @
7220643c
# 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
# "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.
mssql.url
=
jdbc:jtds:sqlserver://mssql-server:1433/tempdb
mssql.username
=
SA
mssql.password
=
yourStrong(!)Password
test/plugin/scenarios/mssql-jtds-scenario/src/main/resources/log4j2.xml
0 → 100644
浏览文件 @
7220643c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<Configuration
status=
"WARN"
>
<Appenders>
<Console
name=
"Console"
target=
"SYSTEM_ERR"
>
<PatternLayout
charset=
"UTF-8"
pattern=
"[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"
/>
</Console>
</Appenders>
<Loggers>
<Root
level=
"WARN"
>
<AppenderRef
ref=
"Console"
/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
test/plugin/scenarios/mssql-jtds-scenario/support-version.list
0 → 100644
浏览文件 @
7220643c
# 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
# "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.
1.2.2
1.2.4
1.2.6
1.2.7
1.2.8
1.3.0
1.3.1
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录