Commit e3a66d41 authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Move enqueued jobs counting to a separate method to switch it on/off easily

parent 403b958c
......@@ -33,6 +33,7 @@ probes:
sidekiq:
methods:
- probe_queues
- probe_jobs
- probe_workers
- probe_retries
opts:
......
......@@ -401,6 +401,7 @@ module GitLab
::GitLab::Monitor::SidekiqProber.new(redis_url: @redis_url)
.probe_queues
.probe_jobs
.probe_workers
.probe_retries
.write_to(@target)
......
......@@ -21,15 +21,23 @@ module GitLab
ensure_queue_job_stats_script_loaded
end
def probe_queues # rubocop:disable Metrics/MethodLength
def probe_queues
return self unless connected?
job_stats = {}
Sidekiq::Queue.all.each do |queue|
@metrics.add("sidekiq_queue_size", queue.size, name: queue.name)
@metrics.add("sidekiq_queue_latency", queue.latency, name: queue.name)
end
self
end
def probe_jobs # rubocop:disable Metrics/MethodLength
return self unless connected?
job_stats = {}
Sidekiq::Queue.all.each do |queue|
begin
Sidekiq.redis do |conn|
stats = conn.evalsha(QUEUE_JOB_STATS_SHA, ["queue:#{queue.name}"])
......@@ -37,7 +45,7 @@ module GitLab
end
rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default)
# FIXME: Should we call SCRIPT KILL?
next
return self
end
end
......
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