mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-02 03:58:02 +08:00
docs: polishing zipkin and opentelemetery plugin's docs (#6302)
Co-authored-by: Peter Zhu <starszcan@gmail.com> Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com>
This commit is contained in:
parent
84eced65a9
commit
1407eb9452
BIN
docs/assets/images/plugin/jaeger-1.png
Normal file
BIN
docs/assets/images/plugin/jaeger-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 KiB |
BIN
docs/assets/images/plugin/jaeger-2.png
Normal file
BIN
docs/assets/images/plugin/jaeger-2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 KiB |
@ -74,8 +74,8 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
|
||||
],
|
||||
"plugins": {
|
||||
"opentelemetry": {
|
||||
sampler": {
|
||||
"name": "always_on",
|
||||
"sampler": {
|
||||
"name": "always_on"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ plugin_attr:
|
||||
- By default, SkyWalking uses H2 storage, start SkyWalking directly by
|
||||
|
||||
```shell
|
||||
sudo docker run --name skywalking -d -p 1234:1234 -p 11800:11800 -p 12800:12800 --restart always apache/skywalking-oap-server:8.7.0-es6
|
||||
sudo docker run --name skywalking -d -p 1234:1234 -p 12800:12800 --restart always apache/skywalking-oap-server:8.7.0-es6
|
||||
```
|
||||
|
||||
- Of Course, you may want to use Elasticsearch storage instead
|
||||
@ -133,7 +133,7 @@ plugin_attr:
|
||||
3. Finally, run SkyWalking OAP server:
|
||||
|
||||
```shell
|
||||
sudo docker run --name skywalking -d -p 1234:1234 -p 11800:11800 -p 12800:12800 --restart always --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:8.7.0-es6
|
||||
sudo docker run --name skywalking -d -p 1234:1234 -p 12800:12800 --restart always --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:8.7.0-es6
|
||||
```
|
||||
|
||||
2. SkyWalking Web UI:
|
||||
@ -210,23 +210,15 @@ And then reload APISIX.
|
||||
## Upstream services(Code With SpringBoot)
|
||||
|
||||
```java
|
||||
package com.lenovo.ai.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author cyxinda
|
||||
* @create 2020-05-29 14:02
|
||||
* @desc skywalking test controller
|
||||
**/
|
||||
@RestController
|
||||
public class TestController {
|
||||
@RequestMapping("/uid/{count}")
|
||||
public String getUidList(@PathVariable("count") String countStr, HttpServletRequest request) {
|
||||
System.out.println("counter:::::-----"+countStr);
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
@ -27,14 +27,15 @@ title: Zipkin
|
||||
- [**Attributes**](#attributes)
|
||||
- [**How To Enable**](#how-to-enable)
|
||||
- [**Test Plugin**](#test-plugin)
|
||||
- [run the Zipkin instance](#run-the-zipkin-instance)
|
||||
- [Run the Zipkin instance](#run-the-zipkin-instance)
|
||||
- [Run the Jaeger instance](#run-the-jaeger-instance)
|
||||
- [**Disable Plugin**](#disable-plugin)
|
||||
|
||||
## Name
|
||||
|
||||
[Zipkin](https://github.com/openzipkin/zipkin) is a OpenTracing plugin.
|
||||
[Zipkin](https://github.com/openzipkin/zipkin) an open source distributed tracing system. This plugin is supported to collect tracing and report to Zipkin Collector based on [Zipkin API specification](https://zipkin.io/pages/instrumenting.html).
|
||||
|
||||
It's also works with `Apache SkyWalking`, which is support Zipkin v1/v2 format.
|
||||
It's also works with [Apache SkyWalking](https://skywalking.apache.org/docs/main/latest/en/setup/backend/zipkin-trace/#zipkin-receiver) and [Jaeger](https://www.jaegertracing.io/docs/1.31/getting-started/#migrating-from-zipkin), which are support Zipkin [v1](https://zipkin.io/zipkin-api/zipkin-api.yaml)/[v2](https://zipkin.io/zipkin-api/zipkin2-api.yaml) format. And of course, it can integrate other tracing systems adapted to Zipkin v1/v2 format as well.
|
||||
|
||||
## Attributes
|
||||
|
||||
@ -100,32 +101,79 @@ You also can complete the above operation through the web interface, first add a
|
||||
|
||||
## Test Plugin
|
||||
|
||||
### run the Zipkin instance
|
||||
### Run the Zipkin instance
|
||||
|
||||
e.g. using docker:
|
||||
|
||||
```
|
||||
sudo docker run -d -p 9411:9411 openzipkin/zipkin
|
||||
docker run -d -p 9411:9411 openzipkin/zipkin
|
||||
```
|
||||
|
||||
Here is a test example:
|
||||
|
||||
```shell
|
||||
$ curl http://127.0.0.1:9080/index.html
|
||||
curl http://127.0.0.1:9080/index.html
|
||||
HTTP/1.1 200 OK
|
||||
...
|
||||
```
|
||||
|
||||
Then you can use a browser to access the webUI of Zipkin:
|
||||
|
||||
```
|
||||
http://127.0.0.1:9411/zipkin
|
||||
```
|
||||
Then you can use a browser to access `http://127.0.0.1:9411/zipkin`, the webUI of Zipkin:
|
||||
|
||||
![zipkin web-ui](../../../assets/images/plugin/zipkin-1.jpg)
|
||||
|
||||
![zipkin web-ui list view](../../../assets/images/plugin/zipkin-2.jpg)
|
||||
|
||||
### Run the Jaeger instance
|
||||
|
||||
Besides Zipkin, this plugin supports reporting the traces to Jaeger as well. Here is a sample run on docker.
|
||||
Run Jaeger backend on docker first:
|
||||
|
||||
```
|
||||
docker run -d --name jaeger \
|
||||
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
|
||||
-p 16686:16686 \
|
||||
-p 9411:9411 \
|
||||
jaegertracing/all-in-one:1.31
|
||||
```
|
||||
|
||||
Create a route with Zipkin plugin like Zipkin's example:
|
||||
|
||||
```
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/index.html",
|
||||
"plugins": {
|
||||
"zipkin": {
|
||||
"endpoint": "http://127.0.0.1:9411/api/v2/spans",
|
||||
"sample_ratio": 1,
|
||||
"service_name": "APISIX-IN-SG",
|
||||
"server_addr": "192.168.3.50"
|
||||
}
|
||||
},
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:1980": 1
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
Access the service:
|
||||
|
||||
```shell
|
||||
curl http://127.0.0.1:9080/index.html
|
||||
HTTP/1.1 200 OK
|
||||
...
|
||||
```
|
||||
|
||||
Then you can access `http://127.0.0.1:16686`, the WebUI of Jaeger, to view traceson browser:
|
||||
|
||||
![jaeger web-ui](../../../assets/images/plugin/jaeger-1.png)
|
||||
|
||||
![jaeger web-ui trace](../../../assets/images/plugin/jaeger-2.png)
|
||||
|
||||
## Disable Plugin
|
||||
|
||||
When you want to disable the zipkin plugin, it is very simple,
|
||||
@ -133,7 +181,7 @@ When you want to disable the zipkin plugin, it is very simple,
|
||||
no need to restart the service, it will take effect immediately:
|
||||
|
||||
```shell
|
||||
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/index.html",
|
||||
|
@ -74,8 +74,8 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
|
||||
],
|
||||
"plugins": {
|
||||
"opentelemetry": {
|
||||
sampler": {
|
||||
"name": "always_on",
|
||||
"sampler": {
|
||||
"name": "always_on"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -31,9 +31,9 @@ title: zipkin
|
||||
|
||||
## 名字
|
||||
|
||||
`zipkin`(https://github.com/openzipkin/zipkin) 是一个开源的服务跟踪插件。
|
||||
[Zipkin](https://github.com/openzipkin/zipkin) 是开源的分布调用链追踪系统。该插件基于[Zipkin API规范](https://zipkin.io/pages/instrumenting.html),支持收集跟踪信息,并上报 Zipkin Collector。
|
||||
|
||||
它还可以在 “Apache SkyWalking” 上运行,支持 Zipkin v1/v2 格式。
|
||||
> 它还能够与适配了 Zipkin [v1](https://zipkin.io/zipkin-api/zipkin-api.yaml)/[v2](https://zipkin.io/zipkin-api/zipkin2-api.yaml) 的 [Apache SkyWalking](https://skywalking.apache.org/docs/main/latest/en/setup/backend/zipkin-trace/#zipkin-receiver) 和 [Jaeger](https://www.jaegertracing.io/docs/1.31/getting-started/#migrating-from-zipkin)。当然,它也能够与其它支持 Zipkin v1/v2 数据格式的调用链追踪系统集成。
|
||||
|
||||
## 属性
|
||||
|
||||
@ -104,33 +104,80 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
|
||||
e.g. 用 docker:
|
||||
|
||||
```
|
||||
sudo docker run -d -p 9411:9411 openzipkin/zipkin
|
||||
docker run -d -p 9411:9411 openzipkin/zipkin
|
||||
```
|
||||
|
||||
测试示例:
|
||||
|
||||
```shell
|
||||
$ curl http://127.0.0.1:9080/index.html
|
||||
curl http://127.0.0.1:9080/index.html
|
||||
HTTP/1.1 200 OK
|
||||
...
|
||||
```
|
||||
|
||||
打开浏览器,访问 Zipkin 的 web 页面:
|
||||
|
||||
```
|
||||
http://127.0.0.1:9411/zipkin
|
||||
```
|
||||
在浏览器访问`http://127.0.0.1:9411/zipkin`,在 Zipkin WebUI 上查询 traces:
|
||||
|
||||
![zipkin web-ui](../../../assets/images/plugin/zipkin-1.jpg)
|
||||
|
||||
![zipkin web-ui list view](../../../assets/images/plugin/zipkin-2.jpg)
|
||||
|
||||
### Run the Jaeger instance
|
||||
|
||||
除了对接 Zipkin,该插件也支持将 traces 上报到 Jaeger。下面运行在`docker`环境上的示例:
|
||||
首先,运行 Jaeger 后端服务:
|
||||
|
||||
```
|
||||
docker run -d --name jaeger \
|
||||
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
|
||||
-p 16686:16686 \
|
||||
-p 9411:9411 \
|
||||
jaegertracing/all-in-one:1.31
|
||||
```
|
||||
|
||||
创建路由,并且配置 Zipkin:
|
||||
|
||||
```
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/index.html",
|
||||
"plugins": {
|
||||
"zipkin": {
|
||||
"endpoint": "http://127.0.0.1:9411/api/v2/spans",
|
||||
"sample_ratio": 1,
|
||||
"service_name": "APISIX-IN-SG",
|
||||
"server_addr": "192.168.3.50"
|
||||
}
|
||||
},
|
||||
"upstream": {
|
||||
"type": "roundrobin",
|
||||
"nodes": {
|
||||
"127.0.0.1:1980": 1
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
访问服务:
|
||||
|
||||
```shell
|
||||
curl http://127.0.0.1:9080/index.html
|
||||
HTTP/1.1 200 OK
|
||||
...
|
||||
```
|
||||
|
||||
然后在浏览器中打开`http://127.0.0.1:16686`,在 Jaeger WebUI 上查询 traces:
|
||||
|
||||
![jaeger web-ui](../../../assets/images/plugin/jaeger-1.png)
|
||||
|
||||
![jaeger web-ui trace](../../../assets/images/plugin/jaeger-2.png)
|
||||
|
||||
## 禁用插件
|
||||
|
||||
当你想去掉插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
|
||||
|
||||
```shell
|
||||
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
|
||||
{
|
||||
"methods": ["GET"],
|
||||
"uri": "/index.html",
|
||||
|
Loading…
Reference in New Issue
Block a user