Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
dfadae71
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
dfadae71
编写于
3月 17, 2016
作者:
Z
zhang.xin
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
97adb363
194a33c0
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
503 addition
and
148 deletion
+503
-148
BUILD_DOC.md
BUILD_DOC.md
+115
-0
README.md
README.md
+22
-126
skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Constants.java
...src/main/java/com/ai/cloud/skywalking/conf/Constants.java
+1
-1
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginCfg.java
...c/main/java/com/ai/cloud/skywalking/plugin/PluginCfg.java
+0
-1
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
...ywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
+10
-1
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceException.java
...cloud/skywalking/plugin/interceptor/EnhanceException.java
+13
-0
skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml
skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml
+14
-2
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/HttpClientExecuteInterceptor.java
...ng/httpClient/v4/plugin/HttpClientExecuteInterceptor.java
+3
-3
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/define/AbstractHttpClientPluginDefine.java
...ient/v4/plugin/define/AbstractHttpClientPluginDefine.java
+1
-10
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/define/DefaultRequestDirectorPluginDefine.java
.../v4/plugin/define/DefaultRequestDirectorPluginDefine.java
+22
-0
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/resources/skywalking-plugin.def
...lient-4.x-plugin/src/main/resources/skywalking-plugin.def
+2
-1
skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/skywalking/httpClient/v4/plugin/TestHttpClientV42.java
...rg/skywalking/httpClient/v4/plugin/TestHttpClientV42.java
+60
-0
skywalking-sdk-plugin/pom.xml
skywalking-sdk-plugin/pom.xml
+5
-3
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/pom.xml
...king-httpClient-4.x-plugin-dubbox-rest-attachment/pom.xml
+79
-0
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/main/java/org/skywalking/httpClient/v4/plugin/dubbox/rest/attachment/DubboxRestHeadSetterAttachment.java
...ubbox/rest/attachment/DubboxRestHeadSetterAttachment.java
+32
-0
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/main/resources/skywalking-plugin.def
...-rest-attachment/src/main/resources/skywalking-plugin.def
+1
-0
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/java/test/skywalking/httpClient/v4x/plugin/dubbox/rest/attachment/TestHttpClientV43.java
.../v4x/plugin/dubbox/rest/attachment/TestHttpClientV43.java
+60
-0
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/resources/log4j2.xml
...ugin-dubbox-rest-attachment/src/test/resources/log4j2.xml
+16
-0
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/resources/sky-walking.auth
...ubbox-rest-attachment/src/test/resources/sky-walking.auth
+47
-0
未找到文件。
BUILD_DOC.md
0 → 100644
浏览文件 @
dfadae71
### 部署第三方软件
-
JDK 1.7
-
安装zookeeper 3.4.6
-
安装apache hbase 1.1.2
-
安装mysql
-
安装tomcat 7
-
redis-3.0.5
### 编译安装SkyWalking Server
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-server
$mvn
package
-Dmaven
.test.skip
=
true
$cd
github/sky-walking/skywalking-server/target/installer
```
-
拷贝installer到服务器
-
根据服务器环境修改/config/config.properties
```
properties
#服务器收集数据监听端口
server.port
=
34000
#数据缓存文件目录,请确保此目录有一定的存储容量
buffer.data_buffer_file_parent_directory
=
D:/test-data/data/buffer
#偏移量注册文件的目录,这里为系统绝对路径
registerpersistence.register_file_parent_directory
=
d:/test-data/data/offset
#hbase zk quorum,hbase的zk地址
hbaseconfig.zk_hostname
=
10.1.235.197,10.1.235.198,10.1.235.199
#hbase zk port,hbase的zk使用端口
hbaseconfig.client_port
=
29181
#告警数据暂存的Redis配置
alarm.redis_server
=
10.1.241.18:16379
```
-
启动服务
```
shell
$cd
installer/bin
$.
/swserver.sh
```
-
可根据需要部署多个实例
-
启动服务前,请注意hbase的客户端使用机器名而非ip连接主机,请在server所在机器上正确配置hosts文件,否则会造成数据无法入库
### 编译安装SkyWalking Alarm
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-alarm
$mvn
package
-Dmaven
.test.skip
=
true
$cd
github/sky-walking/skywalking-alarm/target/installer
```
-
拷贝installer到服务器
-
根据服务器环境修改/config/config.properties
```
properties
#zookeeper连接地址,用于协调集群,可以和hbase的zookeeper共用
zkpath.connect_str
=
10.1.241.18:29181,10.1.241.19:29181,10.1.241.20:29181
#管理数据库的JDBC连接信息
#数据库连接地址
db.url
=
jdbc:mysql://10.1.241.20:31306/sw_db
#数据库用户名
db.user_name
=
sw_dbusr01
#数据库密码
db.password
=
sw_dbusr01
#告警信息存在的redis服务器地址,需要和skywalking-server的alarm.redis_server设置一致
alarm.redis_server
=
127.0.0.1:6379
```
-
启动服务
```
shell
$cd
installer/bin
$.
/sw-alarm-server.sh
```
-
可根据需要部署多个实例,根据实例启动数量,自动负载均衡
### 编译安装SkyWalking WebUI
-
修改配置文件config.properties
```
properties
#hbase的连接地址
hbaseconfig.quorum
=
10.1.235.197,10.1.235.198,10.1.235.199
hbaseconfig.client_port
=
29181
```
-
修改配置文件jdbc.properties
```
properties
#管理数据库的JDBC连接信息
jdbc.url
=
jdbc:mysql://10.1.228.202:31316/test
jdbc.username
=
devrdbusr21
jdbc.password
=
devrdbusr21
```
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-webui
$mvn
package
```
-
初始化管理数据库
根据
[
数据库脚本
](
https://github.com/wu-sheng/sky-walking/blob/master/skywalking-webui/src/main/sql/table.mysql
)
初始化管理数据库。其中,脚本中如下SQL片段需要修改:
```
sql
--配置告警邮件的发送人和SMTP信息
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1000
,
'mail_info'
,
'{
\"
mail.host
\"
:
\"
mail.asiainfo.com
\"
,
\"
mail.transport.protocol
\"
:
\"
smtp
\"
,
\"
mail.smtp.auth
\"
:
\"
true
\"
,
\"
mail.smtp.starttls.enable
\"
:
\"
false
\"
,
\"
mail.username
\"
:
\"
testA
\"
,
\"
mail.password
\"
:
\"
******
\"
,
\"
mail.account.prefix
\"
:
\"
@asiainfo.com
\"
}'
,
'json'
,
'默认邮件发送人信息'
,
'2015-12-10 11:54:06'
,
'A'
,
'2015-12-10 11:54:06'
);
--配置部署页面地址,用于告警邮件内的链接
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1001
,
'portal_addr'
,
'http://10.1.235.197:48080/skywalking/'
,
'string'
,
'默认门户地址'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
--配置SkyWalking Server的集群地址(内网地址)
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1002
,
'servers_addr'
,
'10.1.235.197:34000;10.1.235.197:35000;'
,
'string'
,
'日志采集地址'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
--配置SkyWalking Server的集群地址(外网地址)
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1003
,
'servers_addr_1'
,
'60.194.3.183:34000;60.194.3.183:35000;60.194.3.184:34000;60.194.3.184:35000;'
,
'string'
,
'日志采集地址-外网'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
```
-
上传war包到服务器,启动Tomcat服务器
### 编译安装SkyWalking Analysis
暂未提供
## 使用maven发布各插件工程
-
发布skywalking-sdk-plugin下的各子工程(dubbo-plugin,spring-plugin,web-plugin,jdbc-plugin,httpclient-4.2.x-plugin,httpclient-4.3.x-plugin)
-
请跳过maven.test环节,避免打包失败
```
properties
-Dmaven.test.skip
=
true
```
\ No newline at end of file
README.md
浏览文件 @
dfadae71
...
...
@@ -5,16 +5,17 @@ SkyWalking: Large-Scale Distributed Systems Tracing Infrastructure, 是一个对
*
支持国内常用的dubbo以及dubbox等常见RPC框架,支持应用异常的邮件告警
*
通过
[
byte-buddy
](
https://github.com/raphw/byte-buddy
)
,部分插件将通过动态字节码机制,避免代码侵入性,完成监控。
|插件名称|配置文件支持|动态代码机制|代码侵入|
| ----------- |---------| ----------|----------|
|web-plugin|web.xml| - | - |
|dubbo-plugin| dubbo/dubbox配置文件 | - | - |
|spring-plugin| spring配置文件 | - | - |
|jdbc-plugin| jdbc配置文件 | - | - |
|mysql-plugin| - | YES | - |
|httpClient-4.x-plugin| - | YES | - |
|httpclient-4.2.x-plugin| - | - | YES |
|httpclient-4.3.x-plugin| - | - | YES |
|插件名称|配置文件支持|动态代码机制|代码侵入模式|备注|
| ----------- |---------| ----------|----------|----------|
|web-plugin|web.xml| - | - | - |
|dubbo-plugin| dubbo/dubbox配置文件 | - | - | - |
|spring-plugin| spring配置文件 | - | - | - |
|jdbc-plugin| jdbc配置文件 | - | - | - |
|mysql-plugin| - | YES | - | - |
|httpClient-4.x-plugin| - | YES | - | -
|httpClient-4.x-plugin-dubbox-rest-attachment| - | YES | - | 需引用httpClient-4.x-plugin |
|httpclient-4.2.x-plugin| - | - | YES | 需要使用新提供的httpClient包装对象 |
|httpclient-4.3.x-plugin| - | - | YES | 需要使用新提供的httpClient包装对象 |
# 新版本能力规划
*
提供一定的日志数据分析和展现能力,减少或者避免使用团队的二次开发
...
...
@@ -46,121 +47,7 @@ SkyWalking: Large-Scale Distributed Systems Tracing Infrastructure, 是一个对
# Quick Start
## 编译与部署
### 部署第三方软件
-
JDK 1.7
-
安装zookeeper 3.4.6
-
安装apache hbase 1.1.2
-
安装mysql
-
安装tomcat 7
-
redis-3.0.5
### 编译安装SkyWalking Server
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-server
$mvn
package
-Dmaven
.test.skip
=
true
$cd
github/sky-walking/skywalking-server/target/installer
```
-
拷贝installer到服务器
-
根据服务器环境修改/config/config.properties
```
properties
#服务器收集数据监听端口
server.port
=
34000
#数据缓存文件目录,请确保此目录有一定的存储容量
buffer.data_buffer_file_parent_directory
=
D:/test-data/data/buffer
#偏移量注册文件的目录,这里为系统绝对路径
registerpersistence.register_file_parent_directory
=
d:/test-data/data/offset
#hbase zk quorum,hbase的zk地址
hbaseconfig.zk_hostname
=
10.1.235.197,10.1.235.198,10.1.235.199
#hbase zk port,hbase的zk使用端口
hbaseconfig.client_port
=
29181
#告警数据暂存的Redis配置
alarm.redis_server
=
10.1.241.18:16379
```
-
启动服务
```
shell
$cd
installer/bin
$.
/swserver.sh
```
-
可根据需要部署多个实例
-
启动服务前,请注意hbase的客户端使用机器名而非ip连接主机,请在server所在机器上正确配置hosts文件,否则会造成数据无法入库
### 编译安装SkyWalking Alarm
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-alarm
$mvn
package
-Dmaven
.test.skip
=
true
$cd
github/sky-walking/skywalking-alarm/target/installer
```
-
拷贝installer到服务器
-
根据服务器环境修改/config/config.properties
```
properties
#zookeeper连接地址,用于协调集群,可以和hbase的zookeeper共用
zkpath.connect_str
=
10.1.241.18:29181,10.1.241.19:29181,10.1.241.20:29181
#管理数据库的JDBC连接信息
#数据库连接地址
db.url
=
jdbc:mysql://10.1.241.20:31306/sw_db
#数据库用户名
db.user_name
=
sw_dbusr01
#数据库密码
db.password
=
sw_dbusr01
#告警信息存在的redis服务器地址,需要和skywalking-server的alarm.redis_server设置一致
alarm.redis_server
=
127.0.0.1:6379
```
-
启动服务
```
shell
$cd
installer/bin
$.
/sw-alarm-server.sh
```
-
可根据需要部署多个实例,根据实例启动数量,自动负载均衡
### 编译安装SkyWalking WebUI
-
修改配置文件config.properties
```
properties
#hbase的连接地址
hbaseconfig.quorum
=
10.1.235.197,10.1.235.198,10.1.235.199
hbaseconfig.client_port
=
29181
```
-
修改配置文件jdbc.properties
```
properties
#管理数据库的JDBC连接信息
jdbc.url
=
jdbc:mysql://10.1.228.202:31316/test
jdbc.username
=
devrdbusr21
jdbc.password
=
devrdbusr21
```
-
编译工程
```
shell
$cd
github/sky-walking/skywalking-webui
$mvn
package
```
-
初始化管理数据库
根据
[
数据库脚本
](
https://github.com/wu-sheng/sky-walking/blob/master/skywalking-webui/src/main/sql/table.mysql
)
初始化管理数据库。其中,脚本中如下SQL片段需要修改:
```
sql
--配置告警邮件的发送人和SMTP信息
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1000
,
'mail_info'
,
'{
\"
mail.host
\"
:
\"
mail.asiainfo.com
\"
,
\"
mail.transport.protocol
\"
:
\"
smtp
\"
,
\"
mail.smtp.auth
\"
:
\"
true
\"
,
\"
mail.smtp.starttls.enable
\"
:
\"
false
\"
,
\"
mail.username
\"
:
\"
testA
\"
,
\"
mail.password
\"
:
\"
******
\"
,
\"
mail.account.prefix
\"
:
\"
@asiainfo.com
\"
}'
,
'json'
,
'默认邮件发送人信息'
,
'2015-12-10 11:54:06'
,
'A'
,
'2015-12-10 11:54:06'
);
--配置部署页面地址,用于告警邮件内的链接
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1001
,
'portal_addr'
,
'http://10.1.235.197:48080/skywalking/'
,
'string'
,
'默认门户地址'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
--配置SkyWalking Server的集群地址(内网地址)
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1002
,
'servers_addr'
,
'10.1.235.197:34000;10.1.235.197:35000;'
,
'string'
,
'日志采集地址'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
--配置SkyWalking Server的集群地址(外网地址)
INSERT
INTO
`system_config`
(
`config_id`
,
`conf_key`
,
`conf_value`
,
`val_type`
,
`val_desc`
,
`create_time`
,
`sts`
,
`modify_time`
)
VALUES
(
1003
,
'servers_addr_1'
,
'60.194.3.183:34000;60.194.3.183:35000;60.194.3.184:34000;60.194.3.184:35000;'
,
'string'
,
'日志采集地址-外网'
,
'2015-12-10 15:23:53'
,
'A'
,
'2015-12-10 15:23:53'
);
```
-
上传war包到服务器,启动Tomcat服务器
### 编译安装SkyWalking Analysis
暂未提供
## 使用maven发布各插件工程
-
发布skywalking-sdk-plugin下的各子工程(dubbo-plugin,spring-plugin,web-plugin,jdbc-plugin,httpclient-4.2.x-plugin,httpclient-4.3.x-plugin)
-
请跳过maven.test环节,避免打包失败
```
properties
-Dmaven.test.skip
=
true
```
-
参考《
[
代码编译部署说明
](
BUILD_DOC.md
)
》
## 引入核心SDK
无论试用哪种插件,都必须引入
...
...
@@ -180,8 +67,17 @@ INSERT INTO `system_config` (`config_id`,`conf_key`,`conf_value`,`val_type`,`val
</dependency>
```
## 使用全新的main class。原main class,以及参数作为参数传入
```
shell
#原进程启动命令:
java com.company.product.Startup arg0 arg1
#全新的进程启动命令:
java com.ai.cloud.skywalking.plugin.TracingBootstrap com.company.product.Startup arg0 arg1
```
## 根据所需插件,配置应用程序
-
参考
[
SDK用户指南
](
https://github.com/wu-sheng/sky-walking/tree/master/skywalking-sdk-plugin
)
-
参考
《
[
SDK用户指南
](
skywalking-sdk-plugin
)
》
-
注意:插件不会引用所需的第三方组件(如Spring、dubbo、dubbox等),请自行引入所需的版本。
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/conf/Constants.java
浏览文件 @
dfadae71
...
...
@@ -4,7 +4,7 @@ public class Constants {
/**
* 务必严格保持两位的version
*/
public
static
String
SDK_VERSION
=
"1.0
a2
"
;
public
static
String
SDK_VERSION
=
"1.0
b
"
;
public
static
final
String
HEALTH_DATA_SPILT_PATTERN
=
"^~"
;
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/PluginCfg.java
浏览文件 @
dfadae71
...
...
@@ -6,7 +6,6 @@ import java.io.InputStream;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
com.ai.cloud.skywalking.util.StringUtil
;
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceClazz4Interceptor.java
浏览文件 @
dfadae71
...
...
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
com.ai.cloud.skywalking.plugin.PluginCfg
;
import
com.ai.cloud.skywalking.util.StringUtil
;
public
class
EnhanceClazz4Interceptor
{
private
static
Logger
logger
=
LogManager
...
...
@@ -50,13 +51,18 @@ public class EnhanceClazz4Interceptor {
private
void
enhance0
(
String
interceptorDefineClassName
)
throws
InstantiationException
,
IllegalAccessException
,
ClassNotFoundException
{
ClassNotFoundException
,
EnhanceException
{
logger
.
debug
(
"prepare to enhance class by {}."
,
interceptorDefineClassName
);
InterceptorDefine
define
=
(
InterceptorDefine
)
Class
.
forName
(
interceptorDefineClassName
).
newInstance
();
String
enhanceOriginClassName
=
define
.
getBeInterceptedClassName
();
if
(
StringUtil
.
isEmpty
(
enhanceOriginClassName
)){
logger
.
warn
(
"classname of being intercepted is not defined by {}."
,
interceptorDefineClassName
);
return
;
}
logger
.
debug
(
"prepare to enhance class {} by {}."
,
enhanceOriginClassName
,
interceptorDefineClassName
);
...
...
@@ -94,6 +100,9 @@ public class EnhanceClazz4Interceptor {
* required by interceptorDefineClass. <br/>
*/
IAroundInterceptor
interceptor
=
define
.
instance
();
if
(
interceptor
==
null
){
throw
new
EnhanceException
(
"no IAroundInterceptor instance. "
);
}
DynamicType
.
Builder
<?>
newClassBuilder
=
new
ByteBuddy
().
subclass
(
originClass
,
ConstructorStrategy
.
Default
.
IMITATE_SUPER_CLASS
);
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/plugin/interceptor/EnhanceException.java
0 → 100644
浏览文件 @
dfadae71
package
com.ai.cloud.skywalking.plugin.interceptor
;
public
class
EnhanceException
extends
Exception
{
private
static
final
long
serialVersionUID
=
-
2234782755784217255L
;
public
EnhanceException
(
String
message
)
{
super
(
message
);
}
public
EnhanceException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
skywalking-sdk-plugin/httpClient-4.x-plugin/pom.xml
浏览文件 @
dfadae71
...
...
@@ -8,9 +8,12 @@
<artifactId>
skywalking-sdk-plugin
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<artifactId>
skywalking-httpClient-4.x-plugin
</artifactId>
<name>
skywalking-httpClient-4.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<packaging>
jar
</packaging>
<name>
httpclient-4.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
...
...
@@ -23,12 +26,21 @@
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.3
</version>
<scope>
test
</scope>
</dependency>
<!--
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
...
...
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/HttpClientExecuteInterceptor.java
浏览文件 @
dfadae71
...
...
@@ -12,9 +12,9 @@ import com.ai.cloud.skywalking.plugin.interceptor.MethodInvokeContext;
public
class
HttpClientExecuteInterceptor
implements
IAroundInterceptor
{
/**
*
TODO: need laod from config
*
default headname of sky walking context<br/>
*/
public
static
String
traceHearName
=
"
"
;
public
static
String
TRACE_HEAD_NAME
=
"SkyWalking-TRACING-NAME
"
;
private
static
RPCBuriedPointSender
sender
=
new
RPCBuriedPointSender
();
...
...
@@ -35,7 +35,7 @@ public class HttpClientExecuteInterceptor implements IAroundInterceptor {
HttpRequest
httpRequest
=
(
HttpRequest
)
allArguments
[
1
];
httpRequest
.
setHeader
(
traceHearName
,
TRACE_HEAD_NAME
,
"ContextData="
+
sender
.
beforeSend
(
Identification
...
...
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/define/AbstractHttpClientPluginDefine.java
浏览文件 @
dfadae71
package
org.skywalking.httpClient.v4.plugin.define
;
import
io.netty.handler.codec.http.HttpRequest
;
import
javax.xml.ws.spi.http.HttpContext
;
import
org.apache.http.HttpHost
;
import
com.ai.cloud.skywalking.plugin.interceptor.InterceptPoint
;
public
class
AbstractHttpClientPluginDefine
extends
HttpClientPluginDefine
{
...
...
@@ -20,13 +14,10 @@ public class AbstractHttpClientPluginDefine extends HttpClientPluginDefine {
* public final HttpResponse execute(HttpHost target, HttpRequest request,
* HttpContext context)<br/>
*
* since version 4.3,intercept method: doExecute<br/>
*/
@Override
public
InterceptPoint
[]
getBeInterceptedMethods
()
{
return
new
InterceptPoint
[]
{
new
InterceptPoint
(
"doExecute"
),
new
InterceptPoint
(
"execute"
,
HttpHost
.
class
,
HttpRequest
.
class
,
HttpContext
.
class
)
};
new
InterceptPoint
(
"doExecute"
)};
}
}
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/org/skywalking/httpClient/v4/plugin/define/DefaultRequestDirectorPluginDefine.java
0 → 100644
浏览文件 @
dfadae71
package
org.skywalking.httpClient.v4.plugin.define
;
import
com.ai.cloud.skywalking.plugin.interceptor.InterceptPoint
;
public
class
DefaultRequestDirectorPluginDefine
extends
HttpClientPluginDefine
{
/**
* DefaultRequestDirector is default implement.<br/>
* usually use in version 4.0-4.2<br/>
* since 4.3, this class is Deprecated.
*/
@Override
public
String
getBeInterceptedClassName
()
{
return
"org.apache.http.impl.client.DefaultRequestDirector"
;
}
@Override
public
InterceptPoint
[]
getBeInterceptedMethods
()
{
return
new
InterceptPoint
[]
{
new
InterceptPoint
(
"execute"
)};
}
}
skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/resources/skywalking-plugin.def
浏览文件 @
dfadae71
org.skywalking.httpClient.v4.plugin.define.AbstractHttpClientPluginDefine
org.skywalking.httpClient.v4.plugin.define.InternalHttpClientPluginDefine
org.skywalking.httpClient.v4.plugin.define.MinimalHttpClientPluginDefine
\ No newline at end of file
org.skywalking.httpClient.v4.plugin.define.MinimalHttpClientPluginDefine
org.skywalking.httpClient.v4.plugin.define.DefaultRequestDirectorPluginDefine
\ No newline at end of file
skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/skywalking/httpClient/v4/plugin/TestHttpClientV42.java
0 → 100644
浏览文件 @
dfadae71
package
org.skywalking.httpClient.v4.plugin
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.InvocationTargetException
;
import
java.sql.SQLException
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.junit.Test
;
import
com.ai.cloud.skywalking.plugin.TracingBootstrap
;
public
class
TestHttpClientV42
{
@Test
public
void
testsql
()
throws
IllegalAccessException
,
IllegalArgumentException
,
InvocationTargetException
,
NoSuchMethodException
,
SecurityException
,
ClassNotFoundException
{
TracingBootstrap
.
main
(
new
String
[]
{
"org.skywalking.httpClient.v4.plugin.TestHttpClientV42"
});
}
public
static
void
main
(
String
[]
args
)
throws
ClassNotFoundException
,
SQLException
,
InterruptedException
,
ClientProtocolException
,
IOException
{
// 默认的client类。
HttpClient
client
=
new
DefaultHttpClient
();
// 设置为get取连接的方式.
HttpGet
get
=
new
HttpGet
(
"http://www.baidu.com"
);
// 得到返回的response.
HttpResponse
response
=
client
.
execute
(
get
);
// 得到返回的client里面的实体对象信息.
HttpEntity
entity
=
response
.
getEntity
();
if
(
entity
!=
null
)
{
System
.
out
.
println
(
"内容编码是:"
+
entity
.
getContentEncoding
());
System
.
out
.
println
(
"内容类型是:"
+
entity
.
getContentType
());
// 得到返回的主体内容.
InputStream
instream
=
entity
.
getContent
();
try
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
instream
,
"UTF-8"
));
System
.
out
.
println
(
reader
.
readLine
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
instream
.
close
();
}
}
// 关闭连接.
client
.
getConnectionManager
().
shutdown
();
Thread
.
sleep
(
5
*
1000
);
}
}
skywalking-sdk-plugin/pom.xml
浏览文件 @
dfadae71
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.ai.cloud
</groupId>
...
...
@@ -13,8 +14,9 @@
<module>
web-plugin
</module>
<module>
httpclient-4.2.x-plugin
</module>
<module>
httpclient-4.3.x-plugin
</module>
<module>
httpClient-4.x-plugin
</module>
</modules>
<module>
httpClient-4.x-plugin
</module>
<module>
httpClient-4.x-plugin-dubbox-rest-attachment
</module>
</modules>
<packaging>
pom
</packaging>
<name>
skywalking-sdk-plugin
</name>
...
...
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/pom.xml
0 → 100644
浏览文件 @
dfadae71
<?xml version="1.0"?>
<project
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-sdk-plugin
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<artifactId>
skywalking-httpClient-4.x-plugin-dubbox-rest-attachment
</artifactId>
<packaging>
jar
</packaging>
<name>
httpclient-4.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-httpClient-4.x-plugin
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.3
</version>
<scope>
test
</scope>
</dependency>
<!--
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
2.4.1
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.7
</source>
<target>
1.7
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-resources-plugin
</artifactId>
<version>
2.4.3
</version>
<configuration>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/main/java/org/skywalking/httpClient/v4/plugin/dubbox/rest/attachment/DubboxRestHeadSetterAttachment.java
0 → 100644
浏览文件 @
dfadae71
package
org.skywalking.httpClient.v4.plugin.dubbox.rest.attachment
;
import
org.skywalking.httpClient.v4.plugin.HttpClientExecuteInterceptor
;
import
com.ai.cloud.skywalking.plugin.interceptor.IAroundInterceptor
;
import
com.ai.cloud.skywalking.plugin.interceptor.InterceptPoint
;
import
com.ai.cloud.skywalking.plugin.interceptor.InterceptorDefine
;
public
class
DubboxRestHeadSetterAttachment
implements
InterceptorDefine
{
/**
* this method is called as InterceptorDefine<br/>
* don't return be intercepted classname, <br/>
* just run as a pre setter of attribute:HttpClientExecuteInterceptor.TRACE_HEAD_NAME
*/
@Override
public
String
getBeInterceptedClassName
()
{
HttpClientExecuteInterceptor
.
TRACE_HEAD_NAME
=
"Dubbo-Attachments"
;
return
null
;
}
@Override
public
InterceptPoint
[]
getBeInterceptedMethods
()
{
return
null
;
}
@Override
public
IAroundInterceptor
instance
()
{
return
null
;
}
}
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
dfadae71
org.skywalking.httpClient.v4.plugin.dubbox.rest.attachment.DubboxRestHeadSetterAttachment
\ No newline at end of file
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/java/test/skywalking/httpClient/v4x/plugin/dubbox/rest/attachment/TestHttpClientV43.java
0 → 100644
浏览文件 @
dfadae71
package
test.skywalking.httpClient.v4x.plugin.dubbox.rest.attachment
;
import
java.io.IOException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.sql.SQLException
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.Test
;
import
com.ai.cloud.skywalking.plugin.TracingBootstrap
;
public
class
TestHttpClientV43
{
@Test
public
void
testsql
()
throws
IllegalAccessException
,
IllegalArgumentException
,
InvocationTargetException
,
NoSuchMethodException
,
SecurityException
,
ClassNotFoundException
{
TracingBootstrap
.
main
(
new
String
[]
{
"test.skywalking.httpClient.v4x.plugin.dubbox.rest.attachment.TestHttpClientV43"
});
}
public
static
void
main
(
String
[]
args
)
throws
ClassNotFoundException
,
SQLException
,
InterruptedException
{
HttpClientBuilder
httpClientBuilder
=
HttpClientBuilder
.
create
();
// HttpClient
CloseableHttpClient
closeableHttpClient
=
httpClientBuilder
.
build
();
HttpGet
httpGet
=
new
HttpGet
(
"http://www.baidu.com"
);
System
.
out
.
println
(
httpGet
.
getRequestLine
());
try
{
// 执行get请求
HttpResponse
httpResponse
=
closeableHttpClient
.
execute
(
httpGet
);
// 获取响应消息实体
HttpEntity
entity
=
httpResponse
.
getEntity
();
// 响应状态
System
.
out
.
println
(
"status:"
+
httpResponse
.
getStatusLine
());
// 判断响应实体是否为空
if
(
entity
!=
null
)
{
System
.
out
.
println
(
"contentEncoding:"
+
entity
.
getContentEncoding
());
System
.
out
.
println
(
"response content:"
+
EntityUtils
.
toString
(
entity
));
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
// 关闭流并释放资源
closeableHttpClient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
Thread
.
sleep
(
5
*
1000
);
}
}
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/resources/log4j2.xml
0 → 100644
浏览文件 @
dfadae71
<?xml version="1.0" encoding="UTF-8"?>
<Configuration
status=
"error"
>
<Appenders>
<Console
name=
"Console"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d [%t](%F:%L) %-5level %logger{36} - %msg%n"
/>
</Console>
<Console
name=
"Console2"
target=
"SYSTEM_OUT"
>
<PatternLayout
pattern=
"%d [%t](%F:%L) %-5level %logger{36} - %msg%n"
/>
</Console>
</Appenders>
<Loggers>
<Root
level=
"debug"
>
<AppenderRef
ref=
"Console"
/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
skywalking-sdk-plugin/skywalking-httpClient-4.x-plugin-dubbox-rest-attachment/src/test/resources/sky-walking.auth
0 → 100644
浏览文件 @
dfadae71
#skyWalking用户ID
skywalking.user_id=123
#skyWalking应用编码
skywalking.application_code=test
#skywalking auth的环境变量名字
skywalking.auth_system_env_name=SKYWALKING_RUN
#skywalking数据编码
skywalking.charset=UTF-8
#是否打印数据
buriedpoint.printf=true
#埋点异常的最大长度
buriedpoint.max_exception_stack_length=4000
#业务字段的最大长度
buriedpoint.businesskey_max_length=300
#过滤异常
buriedpoint.exclusive_exceptions=java.lang.RuntimeException
#最大发送者的连接数阀比例
sender.connect_percent=100
#发送服务端配置
sender.servers_addr=127.0.0.1:34000
#最大发送的副本数量
sender.max_copy_num=2
#发送的最大长度
sender.max_send_length=20000
#当没有Sender时,尝试获取sender的等待周期
sender.retry_get_sender_wait_interval=2000
#是否开启发送消息
sender.is_off=false
#最大消费线程数
consumer.max_consumer=2
#消费者最大等待时间
consumer.max_wait_time=5
#发送失败等待时间
consumer.consumer_fail_retry_wait_interval=50
#每个Buffer的最大个数
buffer.buffer_max_size=18000
#Buffer池的最大长度
buffer.pool_size=5
#发送检查线程检查周期
senderchecker.check_polling_time=200
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录