You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2020/11/09 00:13:01 UTC

[apisix] branch master updated: change: disable skywalking by default. (#2632)

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

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new ebf0563  change: disable skywalking by default. (#2632)
ebf0563 is described below

commit ebf0563a40dd79ce37ba52c47e018f38c4232d31
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon Nov 9 08:12:52 2020 +0800

    change: disable skywalking by default. (#2632)
    
    * fix: disable skywalking by default.
    
    Close #2623.
    
    * trailing sw
    
    * clean test
---
 conf/config-default.yaml        |  2 +-
 doc/plugins/skywalking.md       | 24 +++++++++++++++++++++++-
 doc/zh-cn/plugins/skywalking.md | 24 +++++++++++++++++++++++-
 t/APISIX.pm                     |  5 +++++
 t/admin/plugins.t               |  2 +-
 t/debug/debug-mode.t            |  1 -
 t/plugin/skywalking.t           | 13 +++++++++++++
 7 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index 7ec3915..ac5950d 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -199,7 +199,7 @@ plugins:                          # plugin list
   - syslog
   - batch-requests
   - http-logger
-  - skywalking
+  #- skywalking
   - echo
   - authz-keycloak
   - uri-blocker
diff --git a/doc/plugins/skywalking.md b/doc/plugins/skywalking.md
index dff04e1..983daaf 100644
--- a/doc/plugins/skywalking.md
+++ b/doc/plugins/skywalking.md
@@ -42,6 +42,17 @@ The skywalking server can supports both http and grpc protocols. The APISIX clie
 
 ## How To Enable
 
+First of all, enable the skyWalking plugin in the `config.yaml`:
+
+```
+# Add this in config.yaml
+plugins:
+  - ... # plugin you need
+  - skywalking
+```
+
+Then reload APISIX, a background timer will be created to report data to skywalking server.
+
 Here's an example, enable the skywalking plugin on the specified route:
 
 ```shell
@@ -158,7 +169,7 @@ plugin_attr:
 
 ## Disable Plugin
 
-When you want to disable the skyWalking plugin, it is very simple,
+When you want to disable the skyWalking plugin on a route/service, it is very simple,
  you can delete the corresponding json configuration in the plugin configuration,
   no need to restart the service, it will take effect immediately:
 
@@ -182,6 +193,17 @@ $ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1  -H 'X-API-KEY: edd1c9f0343
 
 The skywalking plugin has been disabled now. It works for other plugins.
 
+If you want to disable skywalking plugin totally, for example, stop the background repor timer,
+you need to comment out in the `config.yaml`:
+
+```yaml
+plugins:
+  - ... # plugin you need
+  #- skywalking
+```
+
+And then reload APISIX.
+
 ## Upstream services(Code With SpringBoot)
 
 ```java
diff --git a/doc/zh-cn/plugins/skywalking.md b/doc/zh-cn/plugins/skywalking.md
index 5245226..a2f5a0d 100644
--- a/doc/zh-cn/plugins/skywalking.md
+++ b/doc/zh-cn/plugins/skywalking.md
@@ -43,6 +43,17 @@
 
 ## 如何启用
 
+首先,你需要在 `config.yaml` 里面启用 Skywalking 插件:
+
+```
+# 加到 config.yaml
+plugins:
+  - ... # plugin you need
+  - skywalking
+```
+
+然后重载 APISIX,这样会创建一个后台定时器,向 skywalking 服务器定期上报数据。
+
 下面是一个示例,在指定的 route 上开启了 skywalking 插件:
 
 ```shell
@@ -163,7 +174,7 @@ plugin_attr:
 
 ## 禁用插件
 
-当你想去掉插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
+当你想去掉路由上的插件规则的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
 
 ```shell
 $ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d value='
@@ -185,6 +196,17 @@ $ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1  -H 'X-API-KEY: edd1c9f0343
 
 现在就已经移除了 Skywalking 插件了。其他插件的开启和移除也是同样的方法。
 
+如果你想完全禁用 skywalking 插件,比如停掉后台上报数据的定时器,需要在 `config.yaml`
+里把插件注释掉:
+
+```yaml
+plugins:
+  - ... # plugin you need
+  #- skywalking
+```
+
+然后重载 APISIX。
+
 ## 上游服务是 java 的 SpringBoot 示例代码
 
 ```java
diff --git a/t/APISIX.pm b/t/APISIX.pm
index a6ef638..64b5a0f 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -453,6 +453,11 @@ _EOC_
     }
 
     my $yaml_config = $block->yaml_config // $user_yaml_config;
+
+    if ($block->extra_yaml_config) {
+        $yaml_config .= $block->extra_yaml_config;
+    }
+
     my $user_debug_config = $block->debug_config // "";
 
     my $user_files = $block->user_files;
diff --git a/t/admin/plugins.t b/t/admin/plugins.t
index 1291c0d..7aff6af 100644
--- a/t/admin/plugins.t
+++ b/t/admin/plugins.t
@@ -30,7 +30,7 @@ __DATA__
 --- request
 GET /apisix/admin/plugins/list
 --- response_body_like eval
-qr/\["zipkin","request-id","fault-injection","serverless-pre-function","batch-requests","cors","ip-restriction","referer-restriction","uri-blocker","request-validation","openid-connect","wolf-rbac","hmac-auth","basic-auth","jwt-auth","key-auth","consumer-restriction","authz-keycloak","proxy-mirror","proxy-cache","proxy-rewrite","api-breaker","limit-conn","limit-count","limit-req","node-status","redirect","response-rewrite","grpc-transcode","prometheus","echo","http-logger","tcp-logger"," [...]
+qr/\["zipkin","request-id","fault-injection","serverless-pre-function","batch-requests","cors","ip-restriction","referer-restriction","uri-blocker","request-validation","openid-connect","wolf-rbac","hmac-auth","basic-auth","jwt-auth","key-auth","consumer-restriction","authz-keycloak","proxy-mirror","proxy-cache","proxy-rewrite","api-breaker","limit-conn","limit-count","limit-req","node-status","redirect","response-rewrite","grpc-transcode","prometheus","echo","http-logger","tcp-logger"," [...]
 --- no_error_log
 [error]
 
diff --git a/t/debug/debug-mode.t b/t/debug/debug-mode.t
index 9b60bee..263ff8c 100644
--- a/t/debug/debug-mode.t
+++ b/t/debug/debug-mode.t
@@ -83,7 +83,6 @@ loaded plugin and sort by priority: 403 name: kafka-logger
 loaded plugin and sort by priority: 401 name: syslog
 loaded plugin and sort by priority: 400 name: udp-logger
 loaded plugin and sort by priority: 0 name: example-plugin
-loaded plugin and sort by priority: -1100 name: skywalking
 loaded plugin and sort by priority: -2000 name: serverless-post-function
 
 
diff --git a/t/plugin/skywalking.t b/t/plugin/skywalking.t
index 924af7d..e3bf55d 100644
--- a/t/plugin/skywalking.t
+++ b/t/plugin/skywalking.t
@@ -27,6 +27,19 @@ BEGIN {
 
 use t::APISIX 'no_plan';
 
+add_block_preprocessor(sub {
+    my ($block) = @_;
+
+    my $extra_yaml_config = <<_EOC_;
+plugins:
+    - skywalking
+_EOC_
+
+    $block->set_value("extra_yaml_config", $extra_yaml_config);
+
+    $block;
+});
+
 repeat_each(1);
 no_long_string();
 no_root_location();