Skip to content
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

Request duration measurements aren't using a monotonic clock #28

Open
ghost opened this issue Feb 22, 2022 · 0 comments
Open

Request duration measurements aren't using a monotonic clock #28

ghost opened this issue Feb 22, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Feb 22, 2022

Right now Kiev is using the difference between the return values of Time.now to calculate request duration. Instead, it should be using a process' monotonic clock as outlined in the article here: https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/:

To recap: system clock is constantly floating and it doesn't move only forwards. If your calculation of elapsed time is based on it, you're very likely to run into calculation errors or even outages.

At a glance I only found one place where this has to be changed:

began_at = Time.now
error = nil
begin
return_value = yield
rescue StandardError => e
error = e
end
begin
data[:request_duration] = ((Time.now - began_at) * 1000).round(3)

…but there may be more.

@ghost ghost changed the title Request duration measurements use the wrong mechanism Request duration measurements aren't using a monotonic clock Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants