class Sidekiq::Queue
def latency
-
(Float)- in seconds
def latency entry = Sidekiq.redis { |conn| conn.lindex(@rname, -1) } return 0.0 unless entry job = Sidekiq.load_json(entry) enqueued_at = job["enqueued_at"] if enqueued_at if enqueued_at.is_a?(Float) # old format now = Time.now.to_f now - enqueued_at else now = ::Process.clock_gettime(::Process::CLOCK_REALTIME, :millisecond) (now - enqueued_at) / 1000.0 end else 0.0 end end