module Yabeda::Sidekiq
Constants
- LONG_RUNNING_JOB_RUNTIME_BUCKETS
- VERSION
Attributes
jobs_started_at[RW]
Hash of hashes containing all currently running jobs' start timestamps to calculate maximum durations of currently running not yet completed jobs { { queue: “default”, worker: “SomeJob” } => { “jid1” => 100500, “jid2” => 424242 } }
Public Class Methods
labelize(worker, job, queue)
click to toggle source
# File lib/yabeda/sidekiq.rb, line 104 def labelize(worker, job, queue) { queue: queue, worker: worker_class(worker, job) } end
track_max_job_runtime()
click to toggle source
# File lib/yabeda/sidekiq.rb, line 128 def track_max_job_runtime now = Process.clock_gettime(Process::CLOCK_MONOTONIC) ::Yabeda::Sidekiq.jobs_started_at.each do |labels, jobs| oldest_job_started_at = jobs.values.min oldest_job_duration = oldest_job_started_at ? (now - oldest_job_started_at).round(3) : 0 Yabeda.sidekiq.running_job_runtime.set(labels, oldest_job_duration) end end
worker_class(worker, job)
click to toggle source
# File lib/yabeda/sidekiq.rb, line 108 def worker_class(worker, job) if defined?(ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper) if worker.is_a?(ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper) || worker == ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper return job["wrapped"].to_s end end (worker.is_a?(String) || worker.is_a?(Class) ? worker : worker.class).to_s end