You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/03/12 11:44:33 UTC

[GitHub] [skywalking-nginx-lua] dmsolr opened a new pull request #70: [WIP] kong plugin

dmsolr opened a new pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng merged pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r613077182



##########
File path: kong/README.md
##########
@@ -0,0 +1,51 @@
+Apache SkyWalking Nginx Agent For Kong

Review comment:
       It seems this file/doc hasn't been linked from anywhere?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on pull request #70: [WIP] kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-797820125


   > I wonder if it is ok to put the kong plug-in in this repo? I see that kong's plugins are all independent repositories.
   
   We are asking Guanlan about this. Let's see.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on pull request #70: [WIP] kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-817230659


   Please update the release document
   
   > 6. upload rockspec file to luarocks.org login to luarocks.org, the user name is apache-skywalking and the password has been sent to private@skwalking.apache.org.
   
   About how to release multiple luarock files for OpenResty/APISIX and Kong.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] fffonion commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
fffonion commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r613819638



##########
File path: kong/plugins/skywalking/handler.lua
##########
@@ -0,0 +1,80 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local tracer = require("skywalking.tracer")
+local client = require("skywalking.client")
+local Span = require('skywalking.span')
+
+local subsystem = ngx.config.subsystem
+
+local SkyWalkingHandler = {
+    PRIORITY = 100001,
+    VERSION = "0.0.1",
+}
+
+function SkyWalkingHandler:init_worker()
+    require("skywalking.util").set_randomseed()
+end
+
+function SkyWalkingHandler:access(config)
+    if subsystem == "stream" then
+        kong.log.warn("Not supportted to trace \"stream\" request yet.")
+        return
+    end
+
+    if config.sample_ratio == 1 or math.random() * 100 < config.sample_ratio then
+        kong.ctx.plugin.skywalking_sample = true
+
+        if not client:isInitialized() then
+            local metadata_buffer = ngx.shared.tracing_buffer

Review comment:
       This if block can moved to plugin's `init_worker` phase, as it seems is doing a per worker timer spawning. So we can avoid suprises when serving request as well as long tail latencies.
   
   And we are writing to the same key in shared dict below, this will break the use case when there's multiple skywalking plugins being created in Kong.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] dmsolr commented on pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
dmsolr commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-818380875


   Hi all, the PR is ready for review.
   Currently, I prefer to place this plugin as a directory even if it is totally independent plugin. Because the plugin is involved in a few files(now only 3).
   So, we will release the source code with `nginx-lua-agent` but publishing an independent `luarocks` file.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] guanlan commented on pull request #70: [WIP] kong plugin

Posted by GitBox <gi...@apache.org>.
guanlan commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-797826350


   Hi @wu-sheng, I'd suggest having a separate repo for kong plugins.
   See
   https://github.com/Kong/kong-plugin
   for an example.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] moonming commented on pull request #70: [WIP] kong plugin

Posted by GitBox <gi...@apache.org>.
moonming commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-797806452


   I wonder if it is ok to put the kong plug-in in this repo?  I see that kong's plugins are all independent repositories.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] fffonion commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
fffonion commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r613815976



##########
File path: kong/README.md
##########
@@ -0,0 +1,51 @@
+Apache SkyWalking Nginx Agent For Kong
+==========
+
+This plugin base on Apache SkyWalking Nginx Agent for the Kong API gateway to integrate with the Apache SkyWalking distributed tracing system.
+
+## Usage
+
+1. Install the plugin on Kong:
+
+To install kong-plugin-skywalking:
+```bash
+$ luarocks install kong-plugin-skywalking --local
+```
+
+Edit kong.conf:
+```
+plugins = bundled,skywalking
+
+lua_package_path = ${user.home}/.luarocks/share/lua/5.1/?.lua;;
+```
+
+Set environment:
+```bash
+$ export KONG_NGINX_HTTP_LUA_SHARED_DICT="tracing_buffer 128m"
+```
+
+Restart Kong
+
+2. Enabling & configuring plugin:
+
+Add the plugin to an API:
+
+```bash
+$ curl -i -X POST \
+   --url http://localhost:8001/apis/{api_name}/plugins/ \

Review comment:
       `API` entity has been deprecated and removed in recent version of Kong, we can use `Services` here
   ```
   --url http://localhost:8001/services/{service_name}/plugins/ \
   ```

##########
File path: kong/plugins/skywalking/handler.lua
##########
@@ -0,0 +1,80 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local tracer = require("skywalking.tracer")
+local client = require("skywalking.client")
+local Span = require('skywalking.span')
+
+local subsystem = ngx.config.subsystem
+
+local SkyWalkingHandler = {
+    PRIORITY = 100001,
+    VERSION = "0.0.1",
+}
+
+function SkyWalkingHandler:init_worker()
+    require("skywalking.util").set_randomseed()
+end
+
+function SkyWalkingHandler:access(config)
+    if subsystem == "stream" then
+        kong.log.warn("Not supportted to trace \"stream\" request yet.")
+        return
+    end
+
+    if config.sample_ratio == 1 or math.random() * 100 < config.sample_ratio then
+        kong.ctx.plugin.skywalking_sample = true
+
+        if not client:isInitialized() then
+            local metadata_buffer = ngx.shared.tracing_buffer

Review comment:
       This if block can moved to plugin's `init_worker` phase, as it seems is doing a per worker timer spawning. So we can avoid suprises when serving request as well as long tail latencies.
   
   And we are writing to the same key in shared dict below, this will break the use case when there's multiple skywalking plugins being created in Kong. If this is not desired, 

##########
File path: kong/plugins/skywalking/handler.lua
##########
@@ -0,0 +1,80 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local tracer = require("skywalking.tracer")
+local client = require("skywalking.client")
+local Span = require('skywalking.span')
+
+local subsystem = ngx.config.subsystem
+
+local SkyWalkingHandler = {
+    PRIORITY = 100001,
+    VERSION = "0.0.1",
+}
+
+function SkyWalkingHandler:init_worker()
+    require("skywalking.util").set_randomseed()
+end
+
+function SkyWalkingHandler:access(config)
+    if subsystem == "stream" then
+        kong.log.warn("Not supportted to trace \"stream\" request yet.")
+        return
+    end
+
+    if config.sample_ratio == 1 or math.random() * 100 < config.sample_ratio then

Review comment:
       Should this be `config.sample_ratio == 100 or ....`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-818458489


   > So, we will release the source code with nginx-lua-agent but publishing an independent luarocks file.
   
   Make sense to me.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] fffonion commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
fffonion commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r614112135



##########
File path: kong/plugins/skywalking/handler.lua
##########
@@ -0,0 +1,80 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local tracer = require("skywalking.tracer")
+local client = require("skywalking.client")
+local Span = require('skywalking.span')
+
+local subsystem = ngx.config.subsystem
+
+local SkyWalkingHandler = {
+    PRIORITY = 100001,
+    VERSION = "0.0.1",
+}
+
+function SkyWalkingHandler:init_worker()
+    require("skywalking.util").set_randomseed()
+end
+
+function SkyWalkingHandler:access(config)
+    if subsystem == "stream" then
+        kong.log.warn("Not supportted to trace \"stream\" request yet.")
+        return
+    end
+
+    if config.sample_ratio == 1 or math.random() * 100 < config.sample_ratio then
+        kong.ctx.plugin.skywalking_sample = true
+
+        if not client:isInitialized() then
+            local metadata_buffer = ngx.shared.tracing_buffer

Review comment:
       I see the point here. It's fine to have startTimer in access handler then. 👍 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#issuecomment-819545891


   @guanlan We merged, and we are going to release this on Luarocks next week. What else do you need us to do?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on a change in pull request #70: [WIP] kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r593210243



##########
File path: lib/skywalking/tracer.lua
##########
@@ -26,6 +26,10 @@ local metadata_shdict = ngx.shared.tracing_buffer
 local ngx = ngx
 local nginxComponentId = 6000
 
+if kong then
+    nginxComponentId = 6001

Review comment:
       Please update the main repo and UI to support this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] dmsolr commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
dmsolr commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r613837090



##########
File path: kong/plugins/skywalking/handler.lua
##########
@@ -0,0 +1,80 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--    http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local tracer = require("skywalking.tracer")
+local client = require("skywalking.client")
+local Span = require('skywalking.span')
+
+local subsystem = ngx.config.subsystem
+
+local SkyWalkingHandler = {
+    PRIORITY = 100001,
+    VERSION = "0.0.1",
+}
+
+function SkyWalkingHandler:init_worker()
+    require("skywalking.util").set_randomseed()
+end
+
+function SkyWalkingHandler:access(config)
+    if subsystem == "stream" then
+        kong.log.warn("Not supportted to trace \"stream\" request yet.")
+        return
+    end
+
+    if config.sample_ratio == 1 or math.random() * 100 < config.sample_ratio then
+        kong.ctx.plugin.skywalking_sample = true
+
+        if not client:isInitialized() then
+            local metadata_buffer = ngx.shared.tracing_buffer

Review comment:
       Thanks for your review. :)
   I will submit a new PR to fix them.
   
   As I know, `init_worker` cannot access the plugin's configuration(schema)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-nginx-lua] wu-sheng commented on a change in pull request #70: kong plugin

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #70:
URL: https://github.com/apache/skywalking-nginx-lua/pull/70#discussion_r613085978



##########
File path: kong/README.md
##########
@@ -0,0 +1,51 @@
+Apache SkyWalking Nginx Agent For Kong
+==========
+
+This plugin base on Apache SkyWalking Nginx Agent for the Kong API gateway to integrate with the Apache SkyWalking distributed tracing system.
+
+## Usage

Review comment:
       How to install once we have luarocks online?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org