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 2021/11/09 10:27:12 UTC

[GitHub] [apisix] spacewander commented on a change in pull request #5463: feat: introducing prefer_name attribute in datadog plugin

spacewander commented on a change in pull request #5463:
URL: https://github.com/apache/apisix/pull/5463#discussion_r745477999



##########
File path: t/plugin/datadog.t
##########
@@ -395,3 +395,141 @@ message received: apisix\.apisix\.latency:[\d.]+\|h\|#source:apisix,new_tag:must
 message received: apisix\.ingress\.size:[\d]+\|ms\|#source:apisix,new_tag:must,route_name:1,balancer_ip:[\d.]+,response_status:200,scheme:http
 message received: apisix\.egress\.size:[\d]+\|ms\|#source:apisix,new_tag:must,route_name:1,balancer_ip:[\d.]+,response_status:200,scheme:http
 /
+
+
+
+=== TEST 8: testing behaviour with service id

Review comment:
       Is there a test for prefer_name + the route name?

##########
File path: apisix/plugins/datadog.lua
##########
@@ -83,15 +85,24 @@ local function generate_tag(entry, const_tags)
         tags = {}
     end
 
-    -- priority on route name, if not found using the route id.
-    if entry.route_name ~= "" then
+    -- priority on route_name & prefer_name, if not found fall back to the route id
+    if entry.prefer_name and entry.route_name ~= "" then
         core.table.insert(tags, "route_name:" .. entry.route_name)
     elseif entry.route_id and entry.route_id ~= "" then
         core.table.insert(tags, "route_name:" .. entry.route_id)
     end
 
     if entry.service_id and entry.service_id ~= "" then
-        core.table.insert(tags, "service_id:" .. entry.service_id)
+        local svc_id = entry.service_id
+
+        if entry.prefer_name then
+            local svc = service_fetch(svc_id)

Review comment:
       To prevent race and make the report code straightforward, it would be better to fetch the name in the log phase instead of the report process.




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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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