felpasl commented on PR #12696:
URL: https://github.com/apache/apisix/pull/12696#issuecomment-3450931995

   Thanks for the follow-up. Just to clarify: the change includes methods and 
calculations that aren't available through existing NGINX or APISIX variables.
   
   For example:
   
   ``` lua
       latency = function() return (ngx_now() - ngx.req.start_time()) * 1000 
end,
       upstream_latency = function(ctx)
           return ctx.var.upstream_response_time and 
ctx.var.upstream_response_time * 1000 or nil
       end,
       apisix_latency = function(ctx)
           local latency = (ngx_now() - ngx.req.start_time()) * 1000
           local upstream_latency =
               ctx.var.upstream_response_time and 
ctx.var.upstream_response_time * 1000 or 0
           local apisix_latency = latency - upstream_latency
           if apisix_latency < 0 then apisix_latency = 0 end
           return apisix_latency
       end,
       hostname = function() return core.utils.gethostname() end,
       version = function() return core.version.VERSION end,
   ```
   These aren't just references to existing variables — they encapsulate logic 
that calculates values like total latency, APISIX processing time, and upstream 
latency. My proposal is to expose these as named variables so users can access 
them directly in log_format, without needing to replicate the logic themselves.
   
   While many fields (like client_ip, request_method, etc.) are already covered 
by NGINX variables but with other names and having them available as variables 
would simplify custom logging and improve consistency of naming variables 
between default log and log_format across plugins.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to