diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-08-09 14:59:44 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-08-09 14:59:44 +0300 |
commit | 9e19125f391edd90d74d60720a3a8887d9ce1258 (patch) | |
tree | 2db327601cf4a8f3256419d561e7cece1baba21d /lib | |
parent | ce0891aa84c6aa7dbd68b0ff2d4f3f9fbde483a1 (diff) | |
parent | 7ccbb562b161881cffea77b228c2c3d062fcc864 (diff) |
Merge branch 'sh-fix-sidekiq-scheduling-latency' into 'master'
Fix Sidekiq scheduling_latency_s
Closes #65748
See merge request gitlab-org/gitlab-ce!31650
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/sidekiq_logging/structured_logger.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/sidekiq_logging/structured_logger.rb b/lib/gitlab/sidekiq_logging/structured_logger.rb index b17135922f6..60782306ade 100644 --- a/lib/gitlab/sidekiq_logging/structured_logger.rb +++ b/lib/gitlab/sidekiq_logging/structured_logger.rb @@ -39,7 +39,7 @@ module Gitlab # Old gitlab-shell messages don't provide enqueued_at/created_at attributes enqueued_at = payload['enqueued_at'] || payload['created_at'] if enqueued_at - payload['scheduling_latency_s'] = elapsed(Time.iso8601(enqueued_at).to_f) + payload['scheduling_latency_s'] = elapsed_by_absolute_time(Time.iso8601(enqueued_at)) end payload @@ -89,6 +89,10 @@ module Gitlab end end + def elapsed_by_absolute_time(start) + (Time.now.utc - start).to_f.round(3) + end + def elapsed(start) (current_time - start).round(3) end |