Commit 7000ecf0 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Use monotonic time instead of the time of day

This uses a monotonic time instead of the timeofday provided by the
Kernel.

The timeofday is subject to change, if an administrator changes it
manually, or is updated by NTP.
parent 789dc771
...@@ -66,14 +66,14 @@ module Gitlab ...@@ -66,14 +66,14 @@ module Gitlab
def call(env) def call(env)
method = env['REQUEST_METHOD'].downcase method = env['REQUEST_METHOD'].downcase
method = 'INVALID' unless HTTP_METHODS.key?(method) method = 'INVALID' unless HTTP_METHODS.key?(method)
started = Time.now.to_f started = Gitlab::Metrics::System.monotonic_time
health_endpoint = health_endpoint?(env['PATH_INFO']) health_endpoint = health_endpoint?(env['PATH_INFO'])
status = 'undefined' status = 'undefined'
begin begin
status, headers, body = @app.call(env) status, headers, body = @app.call(env)
elapsed = Time.now.to_f - started elapsed = Gitlab::Metrics::System.monotonic_time - started
if !health_endpoint && Gitlab::Metrics.record_duration_for_status?(status) if !health_endpoint && Gitlab::Metrics.record_duration_for_status?(status)
RequestsRackMiddleware.http_request_duration_seconds.observe({ method: method }, elapsed) RequestsRackMiddleware.http_request_duration_seconds.observe({ method: method }, elapsed)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment