Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
dfadae712b
|
|
@ -0,0 +1,115 @@
|
|||
### 部署第三方软件
|
||||
- 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
|
||||
```
|
||||
148
README.md
148
README.md
|
|
@ -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等),请自行引入所需的版本。
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ public class Constants {
|
|||
/**
|
||||
* 务必严格保持两位的version
|
||||
*/
|
||||
public static String SDK_VERSION = "1.0a2";
|
||||
public static String SDK_VERSION = "1.0b";
|
||||
|
||||
public static final String HEALTH_DATA_SPILT_PATTERN = "^~";
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
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")};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
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")};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
org.skywalking.httpClient.v4.plugin.define.AbstractHttpClientPluginDefine
|
||||
org.skywalking.httpClient.v4.plugin.define.InternalHttpClientPluginDefine
|
||||
org.skywalking.httpClient.v4.plugin.define.MinimalHttpClientPluginDefine
|
||||
org.skywalking.httpClient.v4.plugin.define.MinimalHttpClientPluginDefine
|
||||
org.skywalking.httpClient.v4.plugin.define.DefaultRequestDirectorPluginDefine
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<?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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
<?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>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
org.skywalking.httpClient.v4.plugin.dubbox.rest.attachment.DubboxRestHeadSetterAttachment
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?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>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#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
|
||||
|
||||
Loading…
Reference in New Issue