You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/03/13 03:48:04 UTC

[GitHub] [incubator-apisix] moonming opened a new pull request #1241: feature: add skywalking plugin.

moonming opened a new pull request #1241: feature: add skywalking plugin.
URL: https://github.com/apache/incubator-apisix/pull/1241
 
 
   

----------------------------------------------------------------
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


With regards,
Apache Git Services

[GitHub] [incubator-apisix] membphis commented on a change in pull request #1241: feature: add skywalking plugin.

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1241:
URL: https://github.com/apache/incubator-apisix/pull/1241#discussion_r430972468



##########
File path: apisix/plugins/skywalking/client.lua
##########
@@ -0,0 +1,226 @@
+--
+-- 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 core = require("apisix.core")
+local http = require("resty.http")
+local cjson = require('cjson')
+local ngx = ngx
+local ipairs = ipairs
+
+local register = require("skywalking.register")
+
+local _M = {}
+
+local function register_service(conf)
+    local endpoint = conf.endpoint
+
+    local tracing_buffer = ngx.shared['skywalking-tracing-buffer']
+    local service_id = tracing_buffer:get(endpoint .. '_service_id')
+    if service_id then
+        return service_id
+    end
+
+    local service_name = conf.service_name
+    local service = register.newServiceRegister(service_name)
+
+    local httpc = http.new()
+    local res, err = httpc:request_uri(endpoint .. '/v2/service/register',
+                        {
+                            method = "POST",
+                            body = core.json.encode(service),
+                            headers = {
+                                ["Content-Type"] = "application/json",
+                            },
+                        })
+    if not res then

Review comment:
       code style, this style is better
   
   ```lua
   if not res then
       core.log.error(...)
       return nil
   end
   
   if res.status ~= 200 then
       core.log.error(...)
       return nil
   end
   
   tracing_buffer:set(endpoint .. '_service_id', service_id)
   return service_id
   ```




----------------------------------------------------------------
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] [incubator-apisix] moonming merged pull request #1241: feature: add skywalking plugin.

Posted by GitBox <gi...@apache.org>.
moonming merged pull request #1241:
URL: https://github.com/apache/incubator-apisix/pull/1241


   


----------------------------------------------------------------
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] [incubator-apisix] membphis commented on a change in pull request #1241: feature: add skywalking plugin.

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1241:
URL: https://github.com/apache/incubator-apisix/pull/1241#discussion_r430970767



##########
File path: t/plugin/skywalking.t
##########
@@ -0,0 +1,242 @@
+#
+# 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.
+#
+
+BEGIN {

Review comment:
       this is useless, we can remove the code from `18` to `26`.




----------------------------------------------------------------
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