2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
# This grape_logging module (https://github.com/aserafin/grape_logging) makes it
|
|
|
|
# possible to log how much time an API request was queued by Workhorse.
|
|
|
|
module Gitlab
|
|
|
|
module GrapeLogging
|
|
|
|
module Loggers
|
|
|
|
class QueueDurationLogger < ::GrapeLogging::Loggers::Base
|
|
|
|
def parameters(request, _)
|
2022-07-23 23:45:48 +05:30
|
|
|
duration_s = request.env[Gitlab::Middleware::RailsQueueDuration::GITLAB_RAILS_QUEUE_DURATION_KEY].presence
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
return {} unless duration_s
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
{ 'queue_duration_s': duration_s }
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|