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/11 07:24:23 UTC

[GitHub] [apisix] bisakhmondal commented on a change in pull request #5480: refactor: Method for latency calculation and related refactoring

bisakhmondal commented on a change in pull request #5480:
URL: https://github.com/apache/apisix/pull/5480#discussion_r747259274



##########
File path: apisix/utils/log-util.lua
##########
@@ -153,4 +153,27 @@ function _M.get_req_original(ctx, conf)
 end
 
 
+function _M.latency_details_in_ms(ctx)
+    local latency = (ngx.now() - ngx.req.start_time()) * 1000
+    local upstream_latency, apisix_latency = nil, latency
+
+    if ctx.var.upstream_response_time then
+        upstream_latency = ctx.var.upstream_response_time * 1000
+        apisix_latency = apisix_latency - upstream_latency
+
+        -- The latency might be negative, as Nginx uses different time measurements in
+        -- different metrics.
+        -- See https://github.com/apache/apisix/issues/5146#issuecomment-928919399
+        if apisix_latency < 0 then
+            apisix_latency = 0
+        end
+    end
+
+    return {

Review comment:
       Yes. But in this case, I thought a map would be efficient It's easy to pick the respective value through key without checking which param represents what latency. 
   If you suggest, updating the signature. 




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