gitlab-org--gitlab-foss/lib/gitlab/metrics/sidekiq_middleware.rb
micael.bergeron 7fd3ce417f Revert "add metrics tagging to the sidekiq middleware"
This reverts commit d5859bb9d5.
This reverts commit 2b7e03cf69.
This reverts commit 7799a9bc44.
2017-11-08 16:21:08 -05:00

24 lines
747 B
Ruby

module Gitlab
module Metrics
# Sidekiq middleware for tracking jobs.
#
# This middleware is intended to be used as a server-side middleware.
class SidekiqMiddleware
def call(worker, message, queue)
trans = BackgroundTransaction.new(worker.class)
begin
# Old gitlad-shell messages don't provide enqueued_at/created_at attributes
trans.set(:sidekiq_queue_duration, Time.now.to_f - (message['enqueued_at'] || message['created_at'] || 0))
trans.run { yield }
rescue Exception => error # rubocop: disable Lint/RescueException
trans.add_event(:sidekiq_exception)
raise error
ensure
trans.finish
end
end
end
end
end