Merge branch 'sh-fix-sidekiq-scheduling-latency' into 'master'
Fix Sidekiq scheduling_latency_s Closes #65748 See merge request gitlab-org/gitlab-ce!31650
This commit is contained in:
commit
9e19125f39
2 changed files with 7 additions and 3 deletions
|
@ -39,7 +39,7 @@ module Gitlab
|
||||||
# Old gitlab-shell messages don't provide enqueued_at/created_at attributes
|
# Old gitlab-shell messages don't provide enqueued_at/created_at attributes
|
||||||
enqueued_at = payload['enqueued_at'] || payload['created_at']
|
enqueued_at = payload['enqueued_at'] || payload['created_at']
|
||||||
if enqueued_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
|
end
|
||||||
|
|
||||||
payload
|
payload
|
||||||
|
@ -89,6 +89,10 @@ module Gitlab
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def elapsed_by_absolute_time(start)
|
||||||
|
(Time.now.utc - start).to_f.round(3)
|
||||||
|
end
|
||||||
|
|
||||||
def elapsed(start)
|
def elapsed(start)
|
||||||
(current_time - start).round(3)
|
(current_time - start).round(3)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
||||||
describe Gitlab::SidekiqLogging::StructuredLogger do
|
describe Gitlab::SidekiqLogging::StructuredLogger do
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
let(:timestamp) { Time.iso8601('2018-01-01T12:00:00Z') }
|
let(:timestamp) { Time.iso8601('2018-01-01T12:00:00Z') }
|
||||||
let(:created_at) { timestamp }
|
let(:created_at) { timestamp - 1.second }
|
||||||
let(:scheduling_latency_s) { 0.0 }
|
let(:scheduling_latency_s) { 1.0 }
|
||||||
|
|
||||||
let(:job) do
|
let(:job) do
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue