-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(logging) include 'balancer_by_lua' latency in Kong latency #2494
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly this won't do it. The balancer_by_lua
directive can be invoked multiple times during a single request, and the current implementation in this patch will only consider the last invocation of the balancer handler.
You will need to distinguish the first invocation of the balancer handler (via the addr.try_count
variable), and set the KONG_BALANCER_START
variable only once. The same way, KONG_BALANCER_TIME
can only be computed when we are sure that the current balancer invocation will be the last one.
It might be worth considering making this a list of entries, and have a different time for each try. After all, try 1 can, for various reasons (like DNS resolution, or load-balancing algorithm variations), be significantly slower of faster than another try. This would give useful debug information to a user if they were include in the serialized data sent by the logging plugins, for example.
@thefosk do we still need this, or can we close this PR since we have a few debug/latency patches floating around? |
We still need this, as this is missing from the current logging serializers, but as mentioned, a better version of it. |
I will give this another look soon |
you can use the As a side note: on its own the latency here will pretty much always be near 0ms, as the actual dns resolution is done in the |
(cc @thefosk) |
5235fb0
to
25c73a2
Compare
@thibaultcha @thefosk I updated this pr to properly track time spent per try. Please have a look. |
25c73a2
to
3f3fe5b
Compare
3f3fe5b
to
f5cfda0
Compare
This one will do. Updated the commit author + moved the balancer callbacks to the right place in |
balancer_by_lua
latency in Kong latency