module Resque::Plugins::JobStats::Duration
Public Instance Methods
around_perform_job_stats_duration(*args) { || ... }
click to toggle source
Increments the failed count when job is complete
# File lib/resque/plugins/job_stats/duration.rb, line 22 def around_perform_job_stats_duration(*args) start = Time.now yield duration = Time.now - start Resque.redis.lpush(jobs_duration_key, duration) Resque.redis.ltrim(jobs_duration_key, 0, durations_recorded) end
durations_recorded()
click to toggle source
# File lib/resque/plugins/job_stats/duration.rb, line 31 def durations_recorded @durations_recorded || 100 end
job_durations()
click to toggle source
Returns the number of jobs failed
# File lib/resque/plugins/job_stats/duration.rb, line 12 def job_durations Resque.redis.lrange(jobs_duration_key,0,durations_recorded - 1).map(&:to_f) end
job_rolling_avg()
click to toggle source
# File lib/resque/plugins/job_stats/duration.rb, line 35 def job_rolling_avg job_times = job_durations return 0.0 if job_times.size == 0.0 job_times.inject(0.0) {|s,j| s + j} / job_times.size end
jobs_duration_key()
click to toggle source
Returns the key used for tracking job durations
# File lib/resque/plugins/job_stats/duration.rb, line 17 def jobs_duration_key "stats:jobs:#{self.name}:duration" end
longest_job()
click to toggle source
# File lib/resque/plugins/job_stats/duration.rb, line 41 def longest_job job_durations.max.to_f end
reset_job_durations()
click to toggle source
Resets all job durations
# File lib/resque/plugins/job_stats/duration.rb, line 7 def reset_job_durations Resque.redis.del(jobs_duration_key) end