Properly measure request time using Time.monotonic

This commit is contained in:
Alexander Reelsen 2019-03-19 12:51:11 +01:00
parent 45a508c27d
commit c6ac5232db

View file

@ -5,10 +5,10 @@ module Kemal
end end
def call(context : HTTP::Server::Context) def call(context : HTTP::Server::Context)
time = Time.now time = Time.monotonic
call_next(context) call_next(context)
elapsed_text = elapsed_text(Time.now - time) elapsed_text = elapsed_text(Time.monotonic - time)
@io << time << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n' @io << Time.now << ' ' << context.response.status_code << ' ' << context.request.method << ' ' << context.request.resource << ' ' << elapsed_text << '\n'
context context
end end