提交 7c0f47c1 编写于 作者: P peng-yongsheng

Merge branch 'feature/collector-modelization' of...

Merge branch 'feature/collector-modelization' of https://github.com/OpenSkywalking/skywalking into feature/collector-modelization
......@@ -11,7 +11,7 @@ Sky Walking | [中文](README_ZH.md)
[![OpenTracing-1.x Badge](https://img.shields.io/badge/OpenTracing--1.x-enabled-blue.svg)](http://opentracing.io)
* Provide Java agent, **no need to CHANGE any application source code**.
* High performance agent. Only increase extra **10%** cpu cost in 5000+ tps application, even **When collect all traces**, [check test reports](#test-reports).
* High performance agent. Only increase extra **10%** cpu cost in 5000+ tps application, even **when collect all traces**.
* [Supported middlewares, frameworks and libraries](https://github.com/OpenSkywalking/sky-walking/wiki/3.2-supported-list).
* Manual instrumentation
* As an [OpenTracing supported tracer](http://opentracing.io/documentation/pages/supported-tracers)
......
......@@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* @author peng-yongsheng, wu-sheng
*/
public final class Graph<Input> {
public final class Graph<INPUT> {
private int id;
private Node startNode;
private ConcurrentHashMap<Integer, Node> nodeIndex = new ConcurrentHashMap<>();
......@@ -32,13 +32,13 @@ public final class Graph<Input> {
this.id = id;
}
public void start(Input input) {
startNode.execute(input);
public void start(INPUT INPUT) {
startNode.execute(INPUT);
}
public <Output> Node<Input, Output> addNode(NodeHandler<Input, Output> nodeHandler) {
public <OUTPUT> Node<INPUT, OUTPUT> addNode(NodeProcessor<INPUT, OUTPUT> nodeProcessor) {
synchronized (this) {
startNode = new Node(this, nodeHandler);
startNode = new Node(this, nodeProcessor);
return startNode;
}
}
......
......@@ -27,7 +27,7 @@ import org.skywalking.apm.collector.core.framework.Executor;
*
* @author peng-yongsheng, wu-sheng
*/
public class Next<Input> implements Executor<Input> {
public class Next<INPUT> implements Executor<INPUT> {
private final List<Node> nextNodes;
......@@ -42,9 +42,9 @@ public class Next<Input> implements Executor<Input> {
/**
* Drive to the next nodes
*
* @param input
* @param INPUT
*/
@Override public void execute(Input input) {
nextNodes.forEach(node -> node.execute(input));
@Override public void execute(INPUT INPUT) {
nextNodes.forEach(node -> node.execute(INPUT));
}
}
......@@ -19,39 +19,39 @@
package org.skywalking.apm.collector.core.graph;
/**
* The <code>Node</code> in the graph with explicit Input and Output types.
* The <code>Node</code> in the graph with explicit INPUT and OUTPUT types.
*
* @author peng-yongsheng, wu-sheng
*/
public final class Node<Input, Output> {
private final NodeHandler nodeHandler;
private final Next<Output> next;
public final class Node<INPUT, OUTPUT> {
private final NodeProcessor nodeProcessor;
private final Next<OUTPUT> next;
private final Graph graph;
Node(Graph graph, NodeHandler<Input, Output> nodeHandler) {
Node(Graph graph, NodeProcessor<INPUT, OUTPUT> nodeProcessor) {
this.graph = graph;
this.nodeHandler = nodeHandler;
this.nodeProcessor = nodeProcessor;
this.next = new Next<>();
this.graph.checkForNewNode(this);
}
public final <NextOutput> Node<Output, NextOutput> addNext(NodeHandler<Output, NextOutput> nodeHandler) {
public final <NEXTOUTPUT> Node<OUTPUT, NEXTOUTPUT> addNext(NodeProcessor<OUTPUT, NEXTOUTPUT> nodeProcessor) {
synchronized (graph) {
Node<Output, NextOutput> node = new Node<>(graph, nodeHandler);
Node<OUTPUT, NEXTOUTPUT> node = new Node<>(graph, nodeProcessor);
next.addNext(node);
return node;
}
}
final void execute(Input input) {
nodeHandler.process(input, next);
final void execute(INPUT INPUT) {
nodeProcessor.process(INPUT, next);
}
NodeHandler getHandler() {
return nodeHandler;
NodeProcessor getHandler() {
return nodeProcessor;
}
Next<Output> getNext() {
Next<OUTPUT> getNext() {
return next;
}
}
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.graph;
/**
* @author peng-yongsheng, wu-sheng
*/
public interface NodeHandler<Input, Output> {
public interface NodeProcessor<INPUT, OUTPUT> {
/**
* The unique id in the certain graph.
*
......@@ -29,5 +29,5 @@ public interface NodeHandler<Input, Output> {
*/
int id();
void process(Input input, Next<Output> next);
void process(INPUT INPUT, Next<OUTPUT> next);
}
......@@ -31,6 +31,7 @@ import org.junit.Test;
public class GraphManagerTest {
private static PrintStream OUT_REF;
private ByteArrayOutputStream outputStream;
private static String lineSeparator = System.lineSeparator();
@Before
public void initAndHoldOut() {
......@@ -48,13 +49,13 @@ public class GraphManagerTest {
@Test
public void testGraph() {
Graph<String> testGraph = GraphManager.INSTANCE.createIfAbsent(1, String.class);
Node<String, String> node = testGraph.addNode(new Node1Handler());
Node<String, Integer> node1 = node.addNext(new Node2Handler());
Node<String, String> node = testGraph.addNode(new Node1Processor());
Node<String, Integer> node1 = node.addNext(new Node2Processor());
testGraph.start("Input String");
String output = outputStream.toString();
String expected = "Node1 process: s=Input String\n" +
"Node2 process: s=Input String\n";
String expected = "Node1 process: s=Input String" + lineSeparator +
"Node2 process: s=Input String" + lineSeparator;
Assert.assertEquals(expected, output);
}
......@@ -62,14 +63,14 @@ public class GraphManagerTest {
@Test
public void testGraphWithChainStyle() {
Graph<String> graph = GraphManager.INSTANCE.createIfAbsent(2, String.class);
graph.addNode(new Node1Handler()).addNext(new Node2Handler()).addNext(new Node4Handler());
graph.addNode(new Node1Processor()).addNext(new Node2Processor()).addNext(new Node4Processor());
graph.start("Input String");
String output = outputStream.toString();
String expected = "Node1 process: s=Input String\n" +
"Node2 process: s=Input String\n" +
"Node4 process: int=123\n";
String expected = "Node1 process: s=Input String" + lineSeparator +
"Node2 process: s=Input String" + lineSeparator +
"Node4 process: int=123" + lineSeparator;
Assert.assertEquals(expected, output);
}
......@@ -77,21 +78,21 @@ public class GraphManagerTest {
@Test(expected = PotentialAcyclicGraphException.class)
public void testPotentialAcyclicGraph() {
Graph<String> testGraph = GraphManager.INSTANCE.createIfAbsent(3, String.class);
Node<String, String> node = testGraph.addNode(new Node1Handler());
node.addNext(new Node1Handler());
Node<String, String> node = testGraph.addNode(new Node1Processor());
node.addNext(new Node1Processor());
}
@Test
public void testContinueStream() {
Graph<String> graph = GraphManager.INSTANCE.createIfAbsent(4, String.class);
graph.addNode(new Node1Handler()).addNext(new Node2Handler()).addNext(new Node4Handler());
graph.addNode(new Node1Processor()).addNext(new Node2Processor()).addNext(new Node4Processor());
Next next = GraphManager.INSTANCE.findGraph(4).findNext(2);
next.execute(123);
String output = outputStream.toString();
String expected =
"Node4 process: int=123\n";
"Node4 process: int=123" + lineSeparator;
Assert.assertEquals(expected, output);
}
......@@ -99,7 +100,7 @@ public class GraphManagerTest {
@Test(expected = NodeNotFoundException.class)
public void handlerNotFound() {
Graph<String> graph = GraphManager.INSTANCE.createIfAbsent(5, String.class);
graph.addNode(new Node1Handler()).addNext(new Node2Handler()).addNext(new Node4Handler());
graph.addNode(new Node1Processor()).addNext(new Node2Processor()).addNext(new Node4Processor());
Next next = GraphManager.INSTANCE.findGraph(5).findNext(3);
}
......
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.graph;
/**
* @author wusheng
*/
public class Node1Handler implements NodeHandler<String, String> {
public class Node1Processor implements NodeProcessor<String, String> {
@Override public int id() {
return 1;
}
......
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.graph;
/**
* @author wusheng
*/
public class Node2Handler implements NodeHandler<String, Integer> {
public class Node2Processor implements NodeProcessor<String, Integer> {
@Override public int id() {
return 2;
}
......
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.graph;
/**
* @author wusheng
*/
public class Node3Handler implements NodeHandler<Long, Long> {
public class Node3Processor implements NodeProcessor<Long, Long> {
@Override public int id() {
return 3;
}
......
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.graph;
/**
* @author wusheng
*/
public class Node4Handler implements NodeHandler<Integer, Long> {
public class Node4Processor implements NodeProcessor<Integer, Long> {
@Override public int id() {
return 4;
}
......
## Documents
[![cn doc](https://img.shields.io/badge/document-中文-blue.svg)](README_ZH.md)
* Getting Started
* [Quick start](en/Quick-start.md)
* [Deploy Standalone mode collector](en/Deploy-collector-in-standalone-mode.md)
* [Deploy Cluster mode collector](en/Deploy-collector-in-cluster-mode.md)
* [Deploy javaagent](en/Deploy-skywalking-agent.md)
* [Deploy docker image](en/Deploy-docker-image.md)
* [Supported middlewares, frameworks and libraries](Supported-list.md)
* [How to disable plugins?](en/How-to-disable-plugin.md)
* Application Toolkit
* [Overview](en/Applicaton-toolkit.md)
* [OpenTracing Tracer](en/Opentracing.md)
* Logging
* [log4j](en/Application-toolkit-log4j-1.x.md)
* [log4j2](en/Application-toolkit-log4j-2.x.md)
* [logback](en/Application-toolkit-logback-1.x.md)
* [Trace](en/Application-toolkit-trace.md)
* Testing
* [Plugin Test](https://github.com/SkywalkingTest/agent-integration-test-report)
* [Java Agent Performance Test](https://skywalkingtest.github.io/Agent-Benchmarks/)
* Development Guides
* [Skywalking 3 Cross Process Propagation Headers Protocol, v1.0](en/Skywalking-3-Cross-Process-Propagation-Headers-Protocol.md)
* FAQ
\ No newline at end of file
## 中文文档
[![EN doc](https://img.shields.io/badge/document-English-blue.svg)](README.md)
* [项目简介](/README_ZH.md)
* [快速入门](cn/Quick-start-chn.md)
* [部署单机collector](cn/Deploy-collector-in-standalone-mode-CN.md)
* [部署集群collector](cn/Deploy-collector-in-cluster-mode-CN.md)
* [部署探针Agent](cn/Deploy-skywalking-agent-CN.md)
* [部署Collector镜像](cn/Deploy-docker-image.CN.md)
* [中间件,框架与类库支持列表](Supported-list.md)
* [如何关闭特定插件](cn/How-to-disable-plugin-CN.md)
* APM相关介绍资料
* [APM简介(百度百科)](http://baike.baidu.com/link?url=HizLjnUrwvXqPQ4fZH_MA81MA7R_sE-kpdEIfuUHf-yNHhPiEkA97_7FshVR6raiZL6pvbChTZSIgrC1lY6lhq.md)
* [OpenTracing中文版](https://github.com/opentracing-contrib/opentracing-specification-zh.md)
* [JVM内存管理与GC](cn/Memory-Usage-and-GC-info.md)
* Application Toolkit,应用程序工具包
* [概述](cn/sky-walking-application-toolkit-chn.md)
* [OpenTracing Tracer](cn/skywalking-opentracing-chn.md)
* 日志组件
* [log4j组件](cn/sky-walking-application-toolkit-log4j-1.x-chn.md)
* [log4j2组件](cn/sky-walking-application-toolkit-log4j-2.x-chn.md)
* [logback组件](cn/sky-walking-application-toolkit-logback-1.x-chn.md)
* [Trace](cn/sky-walking-application-toolkit-trace-chn.md)
* 测试用例
* [单插件测试用例](cn/Test-Cases-chn.md)
* [测试应用集群](cn/2.0-Demo-Application-Cluster-chn.md)
* 开发指南
* [工程编译指南](cn/How-to-build.md)
* [插件开发指南](cn/Plugin-Development-Guide.md)
* [跨进程追踪上下文传递协议](cn/Skywalking-3-Cross-Process-Propagation-Headers-Protocol-CN.md)
* [探针与Collector间网络协议,v3.2+](cn/How-to-communicate-with-the-collector%3F.md)
* FAQ
* [探针性能测试报告](https://skywalkingtest.github.io/Agent-Benchmarks/.md)
* [Trace查询有数据,但是没有拓扑图和JVM数据?](cn/Trace%E6%9F%A5%E8%AF%A2%E6%9C%89%E6%95%B0%E6%8D%AE%EF%BC%8C%E4%BD%86%E6%98%AF%E6%B2%A1%E6%9C%89%E6%8B%93%E6%89%91%E5%9B%BE%E5%92%8CJVM%E6%95%B0%E6%8D%AE.md)
* [加载探针,Console被GRPC日志刷屏](cn/加载探针,Console被GRPC日志刷屏.md)
\ No newline at end of file
* HTTP Server
* [Tomcat](https://github.com/apache/tomcat) 7
* [Tomcat](https://github.com/apache/tomcat) 8
* [Spring Boot](https://github.com/spring-projects/spring-boot) Web 4.x
* Spring MVC 3.x, 4.x with servlet 3.x
* [Nutz Web Framework](https://github.com/nutzam/nutz) 1.x
* [Struts2 MVC](http://struts.apache.org/) 2.3.x -> 2.5.x
* [Resin](http://www.caucho.com/resin-4.0/) 3
* [Resin](http://www.caucho.com/resin-4.0/) 4
* [Jetty Server](http://www.eclipse.org/jetty/) 9
* HTTP Client
* [Feign](https://github.com/OpenFeign/feign) 9.x
* [Netflix Spring Cloud Feign](https://github.com/spring-cloud/spring-cloud-netflix/tree/master/spring-cloud-starter-feign) 1.1.x, 1.2.x, 1.3.x
* [Okhttp](https://github.com/square/okhttp) 3.x
* [Apache httpclientcomponent](http://hc.apache.org/) 4.2, 4.3
* [Spring RestTemplete](https://github.com/spring-projects/spring-framework) 4.x
* [Jetty Client](http://www.eclipse.org/jetty/) 9
* JDBC
* Mysql Driver 5.x, 6.x
* Oracle Driver
* H2 Driver
* [Sharding-JDBC 1.5.x](https://github.com/shardingjdbc/sharding-jdbc)
* PostgreSQL Driver 8.x, 9.x, 42.x
* RPC Frameworks
* [Dubbo](https://github.com/alibaba/dubbo) 2.5.3
* [Dubbox](https://github.com/dangdangdotcom/dubbox) 2.8.4
* [Motan](https://github.com/weibocom/motan) 0.2
* [gRPC](https://github.com/grpc/grpc-java) 1.6+
* NoSQL
* Redis
* [Jedis](https://github.com/xetorthio/jedis) 2.8
* [MongoDB Java Driver](https://github.com/mongodb/mongo-java-driver) 3.4+
* Memcached Client
* [Spymemcached](https://github.com/couchbase/spymemcached) 2.x
* [Xmemcached](https://github.com/killme2008/xmemcached) 2.x
* Service Discovery
* [Netflix Eureka](https://github.com/Netflix/eureka)
* Spring Ecosystem
* Spring Core Async SuccessCallback/FailureCallback/ListenableFutureCallback 4.x
* OpenTracing community supported
* Motan
* Hprose-java
\ No newline at end of file
## 所需的第三方软件
- 被监控程序要求JDK6+
- sky-walking server和webui要求JDK8+
- Elasticsearch 5.3
- Zookeeper 3.4.10
## 下载发布版本
- 前向[发布页面](https://github.com/OpenSkywalking/skywalking/releases)
## 部署Elasticsearch
- 修改`elasticsearch.yml`文件
- 设置 `cluster.name: CollectorDBCluster`。此名称需要和collector配置文件一致。
- 设置 `node.name: anyname`, 可以设置为任意名字,如Elasticsearch为集群模式,则每个节点名称需要不同。
- 增加如下配置
```
# ES监听的ip地址
network.host: 0.0.0.0
thread_pool.bulk.queue_size: 1000
```
- 启动Elasticsearch
### 部署collector
1. 解压安装包`tar -xvf skywalking-collector.tar.gz`,windows用户可以选择zip包
1. 运行`bin/startup.sh`启动。windows用户为.bat文件。
- `config/application.yml`
```
cluster:
# Zookeeper地址配置
zookeeper:
hostPort: localhost:2181
sessionTimeout: 100000
# agent_server, agent_stream, ui, collector_inside中配置的IP都是Collector所使用的IP地址
agent_server:
jetty:
host: localhost
# The port used
port: 10800
context_path: /
agent_stream:
grpc:
host: localhost
port: 11800
jetty:
host: localhost
port: 12800
context_path: /
ui:
jetty:
host: localhost
port: 12800
context_path: /
collector_inside:
grpc:
host: localhost
port: 11800
storage:
elasticsearch:
cluster_name: CollectorDBCluster
cluster_transport_sniffer: true
# Elastic Search地址信息
cluster_nodes: localhost:9300
index_shards_number: 2
index_replicas_number: 0
```
## Collector集群模式启动
集群模式主要依赖Zookeeper的注册和应用发现能力。所以,你只需要调整 `config/application.yml`中,agent_server, agent_stream, ui, collector_inside这些配置项的ip信息,使用真实的IP地址或者hostname,Collector就会使用集群模式运行。
其次,将elasticsearch的注释取消,并修改集群的节点地址信息。
## 用途说明
单机模式使用本地H2数据库,不支持集群部署。主要用于:预览、功能测试、演示和低压力系统。
## 所需的第三方软件
- JDK8+
## 下载发布版本
- 前向[发布页面](https://github.com/OpenSkywalking/skywalking/releases)
## Quick Start
Collector单机模拟启动简单,提供和集群模式相同的功能,单机模式下除端口被占用的情况下,直接启动即可。
### 部署collector
1. 解压安装包`tar -xvf skywalking-collector.tar.gz`,windows用户可以选择zip包
1. 运行`bin/startup.sh`启动。windows用户为.bat文件。
- `config/application.yml`
```
# 单机模式下无需配置集群相关信息
#cluster:
# zookeeper:
# hostPort: localhost:2181
# sessionTimeout: 100000
# agent_server, agent_stream, ui, collector_inside中配置的IP都是Collector所使用的IP地址
agent_server:
jetty:
host: localhost
# The port used
port: 10800
context_path: /
agent_stream:
grpc:
host: localhost
port: 11800
jetty:
host: localhost
port: 12800
context_path: /
ui:
jetty:
host: localhost
port: 12800
context_path: /
collector_inside:
grpc:
host: localhost
port: 11800
#storage:
# elasticsearch:
# cluster_name: CollectorDBCluster
# cluster_transport_sniffer: true
# Elastic Search地址信息
# cluster_nodes: localhost:9300
# index_shards_number: 2
# index_replicas_number: 0
```
## 使用Elastic Search代替H2存储
由于H2数据库性能的局限性,我们在单机模式下,也支持使用ElasticSearch 5.3作为存储。你需要安装对应的ElasticSearch 5.3,并取消
- 在单机模式下除了支持内置的H2数据库运行,也支持其他的存储(当前已支持的ElasticSearch 5.3以及将会支持的ShardJdbc),安装storage注释,修改配置信息即可。
- [下载Source code](https://github.com/OpenSkywalking/skywalking/releases)并解压,进入解压目录,执行以下命令:
```shell
> docker-compose pull
> docker-compose up
```
- 探针配置的端口是10800。
- 通过http://localhost:8080 访问WebUI
注意:Docker Compose主要用于在本地进行快速环境搭建和测试,请不要通过远程访问默认Docker Compose启动的Collector环境
___
测试环境: docker 17.03.1-ce, docker compose 1.11.2
## Download skywalking agent release version
- Go to [release page](https://github.com/OpenSkwaylking/skywalking/releases)
## Deploy skywalking javaagent
1. Copy the agent package to anywhere you like. The logs, plugins and config are all included in the package.
2. Add -javaagent:/path/to/skywalking-agent/skywalking-agent.jar to VM argument.
New agent package looks like this:
```
+-- skywalking-agent
+-- activations
apm-toolkit-log4j-1.x-activation.jar
apm-toolkit-log4j-2.x-activation.jar
apm-toolkit-logback-1.x-activation.jar
...
+-- config
agent.config
+-- plugins
apm-dubbo-plugin.jar
apm-feign-default-http-9.x.jar
apm-httpClient-4.x-plugin.jar
.....
skywalking-agent.jar
```
- Start your application。
# Advanced features
- All plugins are in `/plugin` folder. The plugin jar is active when it is in there. Remove the plugin jar, it disabled.
- Besides set config through `/config/agent.config`, you can use System.Env and System.Properties(-D) to set config.
- Key of env and properties = `skywalking.` + key in `agent.config` file
- Priority: System.Env > System.Properties(-D) > `/config/agent.config`
- The default logging output folder is `/log`.
# Deploy agent in Tomcat FAQ
- Tomcat 7
Change the first line of `tomcat/bin/catalina.sh`.
```shell
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/skywalking-agent/skywalking-agent.jar"; export CATALINA_OPTS
```
- Tomcat 8
Change the first line of `tomcat/bin/catalina.sh`.
```shell
set "CATALINA_OPTS=... -javaagent:E:\apache-tomcat-8.5.20\skywalking-agent\skywalking-agent.jar -Dconfig=\skywalking\config\dir"
```
\ No newline at end of file
# Disable plugins
删除plugin目录下的相关jar包:`skywalking-agent/plugins/*.jar`
```
+-- skywalking-agent
+-- activations
apm-toolkit-log4j-1.x-activation.jar
apm-toolkit-log4j-2.x-activation.jar
apm-toolkit-logback-1.x-activation.jar
...
+-- config
agent.config
+-- plugins
apm-dubbo-plugin.jar
apm-feign-default-http-9.x.jar
apm-httpClient-4.x-plugin.jar
.....
skywalking-agent.jar
```
\ No newline at end of file
# 部署步骤
1. 部署 Collector
1. [单机模式](Deploy-collector-in-standalone-mode-CN.md)
1. [集群模式](Deploy-collector-in-cluster-mode-CN.md)
1. 部署 webui server, [doc](https://github.com/OpenSkywalking/skywalking-ui#quickstart)
1. 部署 Java Agent,[doc](Deploy-skywalking-agent-CN.md)
1. 重启并访问系统功能,查看UI即可。
\ No newline at end of file
* Dependency the toolkit, such as using maven or gradle
```xml
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-toolkit-log4j-1.x</artifactId>
<version>{project.release.version}</version>
</dependency>
```
&nbsp;&nbsp;&nbsp;[ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.skywalking.apm-toolkit-log4j-1.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.skywalking.apmg-toolkit-log4j-1.x/_latestVersion)
* Config a layout
```properties
log4j.appender.CONSOLE.layout=org.skywalking.apm.toolkit.log.log4j.v1.x.TraceIdPatternLayout
```
* set `%T` in `layout.ConversionPattern` ( In 2.0-2016, you should use %x, [Why change?](https://github.com/wu-sheng/sky-walking/issues/77) )
```properties
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%T] %-5p %c{1}:%L - %m%n
```
* When you use `-javaagent` to active the sky-waking tracer, log4j will output **traceId**, if it existed. If the tracer is inactive, the output will be `TID: N/A`.
* Dependency the toolkit, such as using maven or gradle
```xml
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-toolkit-log4j-2.x</artifactId>
<version>{project.release.version}</version>
</dependency>
```
&nbsp;&nbsp;&nbsp;[ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.skywalking.apm-toolkit-log4j-2.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.skywalking.apm-toolkit-log4j-2.x/_latestVersion)
* Config the `[%traceId]` pattern in your log4j2.xml
```xml
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%traceId] %-5p %c{1}:%L - %m%n"/>
</Console>
</Appenders>
```
* When you use `-javaagent` to active the sky-waking tracer, log4j2 will output **traceId**, if it existed. If the tracer is inactive, the output will be `TID: N/A`.
\ No newline at end of file
* Dependency the toolkit, such as using maven or gradle
```xml
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>skywalking-toolkit-logback-1.x</artifactId>
<version>{project.release.version}</version>
</dependency>
```
&nbsp;&nbsp;&nbsp;[ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.skywalking.apm-toolkit-logback-1.x/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.skywalking.apm-toolkit-logback-1.x/_latestVersion)
* set `%tid` in `Pattern` section of logback.xml
```xml
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="com.a.eye.skywalking.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%tid] [%thread] %-5level %logger{36} -%msg%n</Pattern>
</layout>
</encoder>
</appender>
```
* When you use `-javaagent` to active the sky-waking tracer, logback will output **traceId**, if it existed. If the tracer is inactive, the output will be `TID: N/A`.
\ No newline at end of file
* Dependency the toolkit, such as using maven or gradle
```xml
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-toolkit-trace</artifactId>
<version>${skywalking.version}</version>
</dependency>
```
&nbsp;&nbsp;&nbsp;[ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.skywalking.apm-toolkit-trace/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.skywalking.apm-toolkit-trace/_latestVersion)
* Use `TraceContext.traceId()` API to obtain traceId.
```java
import org.skywalking.apm.toolkit.trace.TraceContext;
...
modelAndView.addObject("traceId", TraceContext.traceId());
```
_Sample codes only_
* Add `@Trace` to any method you want to trace. After that, you can see the span in the Stack.
\ No newline at end of file
# What's sky-walking application toolkit?
Sky-walking application toolkit is a batch of libraries, provided by skywalking APM. Using them, you have a bridge between your application and skywalking APM agent.
_**Most important**_, they will not trigger any runtime or performance issues for your application, whether skywalking tracer is active or not.
# What does bridge mean?
As you known, skywalking agent run by -javeagent VM parameter. So you definitely don't need to change even a single line of your codes. But in some cases, you want to do interop with tracing/APM system. This is the moment you want to use application toolkit.
e.g.
1. Integrate trace context(traceId) into your log component, e.g. log4j, log4j2 and logback.
1. Use CNCF OpenTracing for manually instrumentation.
1. Use Skywalking annotation and interop APIs.
_**Notice**: all toolkits librarries are on bitray.com/jcenter. And make sure their version should be as same as the tracer's version._
\ No newline at end of file
## Required of third party softwares
- JDK 6+(instruments application can run in jdk6)
- JDK8 ( skywalking collector and skywalking webui )
- Elasticsearch 5.2.2 or 5.3, cluster mode or not
- Zookeeper 3.4.10
## Download released version
- Go to [released page](https://github.com/OpenSkywalking/skywalking/releases)
## Deploy Elasticsearch server
- Modify `elasticsearch.yml`
- Set `cluster.name: CollectorDBCluster`
- Set `node.name: anyname`, this name can be any, it based on Elasticsearch.
- Add the following configurations to
```
# The ip used for listening
network.host: 0.0.0.0
thread_pool.bulk.queue_size: 1000
```
- Start Elasticsearch
## Single Node Mode Collector
Single Node collector is easy to deploy, and provides same features as cluster mode. You can use almost all default config to run in this mode. And attention, all the default configs of single node mode, depend on running the collector, traced application, ElasticSearch and Zookeeper in the same machine.
### Deploy collector servers
1. Run `tar -xvf skywalking-collector.tar.gz`
1. Run `bin/startup.sh`
- `config/application.yml`
```
cluster:
# The address of Zookeeper
zookeeper:
hostPort: localhost:2181
sessionTimeout: 100000
# IPs in agent_server, agent_stream, ui, collector_inside are addresses of Collector
agent_server:
jetty:
host: localhost
# The port used
port: 10800
context_path: /
agent_stream:
grpc:
host: localhost
port: 11800
jetty:
host: localhost
port: 12800
context_path: /
ui:
jetty:
host: localhost
port: 12800
context_path: /
collector_inside:
grpc:
host: localhost
port: 11800
storage:
elasticsearch:
cluster_name: CollectorDBCluster
cluster_transport_sniffer: true
# The address of Elastic Search
cluster_nodes: localhost:9300
index_shards_number: 2
index_replicas_number: 0
```
## Cluster Mode Collector
Cluster mode depends on Zookeeper register and application discovery capabilities. So, you just need to adjust the IP config items in `config/application.yml`. Change IP and port configs of agent_server, agent_stream, ui, collector_inside, replace them to the real ip or hostname which you want to use for cluster.
# Usage scenario
Standalong mode collector means don't support cluster. It uses H2 as storage layer implementation, suggest that use only for preview, test, demonstration, low throughputs and small scale system.
# Requirements
* JDK 8+
# Download
* [Releases](https://github.com/OpenSkywalking/skywalking/releases)
# Quick start
You can simplely tar/unzip and startup if ports 10800, 11800, 12800 are free.
- `tar -xvf skywalking-collector.tar.gz` in Linux, or unzip in windows.
- run `bin/startup.sh` or `bin/startup.bat`
You should keep the `config/application.yml` as default.
# Use Elastic Search instead of H2 as storage layer implementation
Even in standalone mode, collector can run with Elastic Search as storage. If so, uncomment the `storage` section in `application.yml`, set the config right.
- [Download source code](https://github.com/OpenSkywalking/skywalking/releases) and unzip source package. Execute following command under the unzipped directory.
```shell
> docker-compose pull
> docker-compose up
```
- The REST-service of collector listening on localhost:10800
- Open http://localhost:8080
Attention: The Docker Compose is only designed for you to run collector in your local machine. If you are running by using our provided docker compose, you can't access the ip:10800.
---
Test environment : docker 17.03.1-ce, docker compose 1.11.2
## Download skywalking agent release version
- Go to [release page](https://github.com/wu-sheng/sky-walking/releases)
## Deploy skywalking javaagent
1. Copy the agent package to anywhere you like. The logs, plugins and config are all included in the package.
2. Add -javaagent:/path/to/skywalking-agent/skywalking-agent.jar to VM argument.
New agent package looks like this:
```
+-- skywalking-agent
+-- activations
apm-toolkit-log4j-1.x-activation.jar
apm-toolkit-log4j-2.x-activation.jar
apm-toolkit-logback-1.x-activation.jar
...
+-- config
agent.config
+-- plugins
apm-dubbo-plugin.jar
apm-feign-default-http-9.x.jar
apm-httpClient-4.x-plugin.jar
.....
skywalking-agent.jar
```
- Start your application。
# Advanced features
- All plugins are in `/plugin` folder. The plugin jar is active when it is in there. Remove the plugin jar, it disabled.
- Besides set config through `/config/agent.config`, you can use System.Env and System.Properties(-D) to set config.
- Key of env and properties = `skywalking.` + key in `agent.config` file
- Priority: System.Env > System.Properties(-D) > `/config/agent.config`
- The default logging output folder is `/log`.
# Deploy agent in Tomcat FAQ
- Tomcat 7
Change the first line of `tomcat/bin/catalina.sh`.
```shell
CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/skywalking-agent/skywalking-agent.jar"; export CATALINA_OPTS
```
- Tomcat 8
Change the first line of `tomcat/bin/catalina.sh`.
```shell
set "CATALINA_OPTS=... -javaagent:E:\apache-tomcat-8.5.20\skywalking-agent\skywalking-agent.jar -Dconfig=\skywalking\config\dir"
```
\ No newline at end of file
# Disable plugins
Delete or remove the specific libraries / jars in `skywalking-agent/plugins/*.jar`
```
+-- skywalking-agent
+-- activations
apm-toolkit-log4j-1.x-activation.jar
apm-toolkit-log4j-2.x-activation.jar
apm-toolkit-logback-1.x-activation.jar
...
+-- config
agent.config
+-- plugins
apm-dubbo-plugin.jar
apm-feign-default-http-9.x.jar
apm-httpClient-4.x-plugin.jar
.....
skywalking-agent.jar
```
\ No newline at end of file
* Dependency the toolkit, such as using maven or gradle
```xml
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-toolkit-opentracing</artifactId>
<version>{project.release.version}</version>
</dependency>
```
&nbsp;&nbsp;&nbsp;[ ![Download](https://api.bintray.com/packages/wu-sheng/skywalking/org.skywalking.apm-toolkit-opentracing/images/download.svg) ](https://bintray.com/wu-sheng/skywalking/org.skywalking.apm-toolkit-opentracing/_latestVersion)
* Use our OpenTracing tracer implementation
```java
Tracer tracer = new org.skywalking.apm.toolkit.opentracing.SkywalkingTracer();
Tracer.SpanBuilder spanBuilder = tracer.buildSpan("/yourApplication/yourService");
```
\ No newline at end of file
# Quick start
1. Deploy Collector
1. [Standalone Mode](Deploy-collector-in-standalone-mode.md)
1. [Cluster Mode](Deploy-collector-in-cluster-mode.md)
1. Deploy webui server, [doc](https://github.com/OpenSkywalking/skywalking-ui#quickstart)
1. Doploy Java Agent,[doc](Deploy-skywalking-agent.md)
1. Reboot your applications, and open UI.
\ No newline at end of file
# Skywalking 3 Cross Process Propagation Headers Protocol
* Version 1.0
This is the first open edition about `Skywalking 3 Cross Process Propagation Headers Protocol`. The skywalking is more likely an APM system, rather than normal distributed tracing system. The Headers is much more complex than them in order to improving analysis performance of collector. You can find many similar mechanism in other commercial APM system.(Some even much more complex than us)
# Header Item
* Header Name: `sw3`
* Header Value: Split by `|`, the parts are following.
## Values
* Trace Segment Id
The trace segment id is the unique id for the part of the distributed trace. Each id is only used in a single thread. The id includes three parts(Long), e.g. `"1.2343.234234234`
1) The first one represents application instance id, which assigned by collector. (most likely just an integer value, would be helpful in protobuf)
2) The second one represents thread id. (In Java most likely just an integer value, would be helpful in protobuf)
3) The third one also has two parts
1) A timestamp, measured in milliseconds
2) A seq, in current thread, between 0(included) and 9999(included)
If you are using other language, you can generate your own id, but make sure it is unique and combined by three longs.
* Span Id
An integer, unique in a trace segment. Start with 0;
* Parent Application Instance
The instance id of the parent node, e.g. for a server of RPC, this id is from the client application instance id.
* Entry Application Instance
The instance id of the entry application. e.g. A distributed trace `A->B->C`, the id is from `A`.
* Peer Host
The peer-host/peer-id from client side. e.g. client uses `182.14.39.1:9080` to access server, this ip:port is the peer host.
_This value can use exchange/compress collector service to get the id(integer) to represent the string. If you use the string, it must start with `#`, others use integer directly._
* Entry Span Operation Name of First Trace Segment
The operation name/id of entry span propagates from `Entry Application Instance`.
_This value can use exchange/compress collector service to get the id(integer) to represent the string. If you use the string, it must start with `#`, others use integer directly._
* Entry Span Operation Name of Parent Trace Segment
The operation name/id of entry span propagates from `Parent Application Instance`.
_This value can use exchange/compress collector service to get the id(integer) to represent the string. If you use the string, it must start with `#`, others use integer directly._
* Distributed Trace Id
The distributed trace id of the whole trace, if in a batch process, it comes from the trace of first batch producer. The rule is as same as `Trace Segment Id` with three Longs.
### Sample value
1. `1.2343.234234234|1|1|1|#127.0.0.1:8080|#/portal/|#/testEntrySpan|1.2343.234234234`
1. `1.2343.234234234|1|1|1|#127.0.0.1:8080|#/portal/|1038|1.2343.234234234`
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册