Module: Sidekiq::ApiUtils
Instance Method Summary collapse
-
#calculate_latency(job) ⇒ Float
private
Calculate the latency in seconds for a job based on its enqueued timestamp.
Instance Method Details
#calculate_latency(job) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculate the latency in seconds for a job based on its enqueued timestamp
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sidekiq/api.rb', line 25 def calculate_latency(job) = job["enqueued_at"] || job["created_at"] return 0.0 unless if .is_a?(Float) # old format Time.now.to_f - else now = ::Process.clock_gettime(::Process::CLOCK_REALTIME, :millisecond) (now - ) / 1000.0 end end |