You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by mi...@apache.org on 2022/01/05 12:01:31 UTC

[incubator-shenyu-website] 01/01: add zipkin plugin doc for shenyu-agent.

This is an automated email from the ASF dual-hosted git repository.

midnight2104 pushed a commit to branch midnight2104
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu-website.git

commit ad7563f6c9155776911db68d4f7fd3b3bebe1237
Author: midnight2104 <LL...@163.com>
AuthorDate: Wed Jan 5 20:01:06 2022 +0800

    add zipkin plugin doc for shenyu-agent.
---
 docs/user-guide/observability/tracing.md           |  67 ++++++++++++++++-
 .../current/user-guide/observability/tracing.md    |  81 +++++++++++++++++++--
 .../agent/shenyu-agent-plugin-tracing-zipkin.png   | Bin 0 -> 150663 bytes
 3 files changed, 141 insertions(+), 7 deletions(-)

diff --git a/docs/user-guide/observability/tracing.md b/docs/user-guide/observability/tracing.md
index 81c6e54..0b857c6 100644
--- a/docs/user-guide/observability/tracing.md
+++ b/docs/user-guide/observability/tracing.md
@@ -74,4 +74,69 @@ plugins:
 
 The SDK used by the opentelemetry plugin is initialized based on `opentelemetry-sdk-extension-autoconfigure`. For more usage, please refer to [OpenTelemetry SDK AutoConfiguration Instructions](https://github.com/open-telemetry/opentelemetry-java/tree/v1.9.1/sdk-extensions/autoconfigure#opentelemetry-sdk-autoconfigure)
 
-#### zipkin
+
+##### zipkin
+
+| Name                 |  Type  | Default       | Description                     |
+| :------------------- | :----: | :----------- | :----------------------- |
+| SERVICE_NAME         | String | shenyu-agent | The name displayed in the traces system |
+| URL_VERSION         | String | /api/v2/spans | zipkin url version |
+| SAMPLER_TYPE  | String | const        | zipkin sampler type        |
+| SAMPLER_PARAM | String | 1            | zipkin sampler param      |
+
+
+## Agent Plugin Tracing Zipkin
+
+- modify yaml file
+
+Specify the use of the `zipkin` plugin via `supports.tracing` in the `shenyu-agent.yaml` file, and fill in the `zipkin` configuration information via `plugins.tracing`.
+
+```yaml
+appName: shenyu-agent
+supports:
+  tracing:
+    - zipkin
+
+plugins:
+  tracing:
+    zipkin:
+      host: "localhost"
+      port: 9411
+      props:
+        SERVICE_NAME: "shenyu-agent"
+        URL_VERSION: "/api/v2/spans"
+        SAMPLER_TYPE: "const"
+        SAMPLER_PARAM: "1"
+```
+
+Regarding the configuration of interception points, by default all plugins of the gateway have been added with link tracing interception points. If you don't want to record the link information of a particular plugin, you can remove the target class in the `tracing-point.yaml` file.
+
+- repackage
+
+Once the configuration information has been changed, the `shenyu-agent-dist` module needs to be repackaged.
+
+```shell
+> cd shenyu-agent-dist
+> mvn clean package 
+```
+
+- start zipkin-server
+
+please see [zipkin-quickstart](https://zipkin.io/pages/quickstart) to start `zipkin-server` .
+
+- start apache shenyu gateway
+
+When starting the `Apache ShenYu` gateway, add the `-javaagent` parameter and specify the path to `shenyu-agent.jar` in the parameter.
+
+- tracing test 
+    - Reference [Deployment](../../deployment/deployment-local.md) to start `shenyu-admin`.
+    - Start the gateway by referring to the above procedure.
+    - Refer to [Quick start with Http](../../quick-start/quick-start-http.md) to start `shenyu-examples-http`.
+    - Launch a request to the gateway.
+    > GET http://localhost:9195/http/order/findById?id=999
+    >
+    > Accept: application/json
+
+    - After a successful request, you can see that the link log has been reported to zipkin:
+      ![](/img/shenyu/agent/shenyu-agent-plugin-tracing-zipkin.png)
+    
diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/observability/tracing.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/observability/tracing.md
index 05de6d6..afc0223 100644
--- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/observability/tracing.md
+++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/observability/tracing.md
@@ -6,7 +6,7 @@ description: Tracing access
 
 此篇文章是介绍如何使用 `Apache ShenYu Agent`中的tracing功能。
 
-## 目录结构。
+## 目录结构
 
 ```text
 .
@@ -22,8 +22,9 @@ description: Tracing access
 └── shenyu-agent.jar
 ```
 
-## 编辑配置文件(shenyu-agent.yaml)
+## 配置文件
 
+配置文件 `shenyu-agent.yaml` 位于 `shenyu-agent-dist` 模块中:
 ```yaml
 appName: shenyu-agent
 supports:
@@ -42,9 +43,13 @@ plugins:
         JAEGER_SAMPLER_TYPE: "const"
         JAEGER_SAMPLER_PARAM: "1"
     zipkin:
-      host: 
-      port: 
+      host: "localhost"
+      port: 9411
       props:
+        SERVICE_NAME: "shenyu-agent"
+        URL_VERSION: "/api/v2/spans"
+        SAMPLER_TYPE: "const"
+        SAMPLER_PARAM: "1"
     opentelemetry:
       props:
         otel.traces.exporter: jaeger #zipkin #otlp
@@ -52,7 +57,7 @@ plugins:
         otel.exporter.jaeger.endpoint: "http://localhost:14250/api/traces"
 ```
 
-- 在 supports 中选择要使用的插件,如果不需要则去除
+- 在 supports 中选择要使用的插件,如果不需要则去除。
 - 在 plugins 中配置插件的参数,其中各插件props参数的具体使用见下面几个表格:
 
 ##### jaeger
@@ -72,4 +77,68 @@ plugins:
 
 opentelemetry 插件使用的sdk基于 `opentelemetry-sdk-extension-autoconfigure` 初始化,更多使用请参考 [OpenTelemetry SDK自动配置说明](https://github.com/open-telemetry/opentelemetry-java/tree/v1.9.1/sdk-extensions/autoconfigure#opentelemetry-sdk-autoconfigure)
 
-##### Zipkin
+##### zipkin
+
+| 名称                 |  类型  | 默认值       | 说明                     |
+| :------------------- | :----: | :----------- | :----------------------- |
+| SERVICE_NAME         | String | shenyu-agent | 在traces系统中显示的名称 |
+| URL_VERSION         | String | /api/v2/spans | Zipkin的版本 |
+| SAMPLER_TYPE  | String | const        | Zipkin 采样率类型        |
+| SAMPLER_PARAM | String | 1            | Zipkin 采样率参数        |
+
+
+## 使用 zipkin 插件
+
+- 修改配置文件
+
+在 `shenyu-agent.yaml` 文件中通过`supports.tracing`指定使用 `zipkin` 插件,通过 `plugins.tracing` 填写 `zipkin` 的配置信息。
+
+```yaml
+appName: shenyu-agent
+supports:
+  tracing:
+    - zipkin
+
+plugins:
+  tracing:
+    zipkin:
+      host: "localhost"
+      port: 9411
+      props:
+        SERVICE_NAME: "shenyu-agent"
+        URL_VERSION: "/api/v2/spans"
+        SAMPLER_TYPE: "const"
+        SAMPLER_PARAM: "1"
+```
+
+关于拦截点的配置,默认已经对网关的全部插件加上了链路追踪的拦截点,如果不想记录某个插件的链路信息,可以在 `tracing-point.yaml` 文件中去掉目标类。
+
+- 重新打包
+
+配置信息修改完成后,需要重新打包 `shenyu-agent-dist` 模块:
+
+```shell
+> cd shenyu-agent-dist
+> mvn clean install 
+```
+
+- 启动 zipkin-server
+
+请参考 [zipkin-quickstart](https://zipkin.io/pages/quickstart) 启动 `zipkin-server` 。
+
+- 启动网关
+
+在启动 `Apache ShenYu` 网关时,加上 `-javaagent` 参数,在参数中指定 `shenyu-agent.jar` 的路径。
+
+- 测试
+   - 参考 [运维部署](../../deployment/deployment-local.md) 的相关文章,启动 `shenyu-admin`;
+   - 参考上述操作步骤,启动网关;
+   - 参考 [Http快速开始](../../quick-start/quick-start-http.md) ,启动 `shenyu-examples-http`。
+   - 向网关发起请求:
+   > GET http://localhost:9195/http/order/findById?id=999
+   >
+   > Accept: application/json
+
+   - 请求成功后,可以看到链路日志已经上报到zipkin中:
+   ![](/img/shenyu/agent/shenyu-agent-plugin-tracing-zipkin.png)
+    
\ No newline at end of file
diff --git a/static/img/shenyu/agent/shenyu-agent-plugin-tracing-zipkin.png b/static/img/shenyu/agent/shenyu-agent-plugin-tracing-zipkin.png
new file mode 100644
index 0000000..183c44e
Binary files /dev/null and b/static/img/shenyu/agent/shenyu-agent-plugin-tracing-zipkin.png differ