<img src=“https://secure.travis-ci.org/alanpeabody/resque-job-stats.png?branch=master” />
Job centric stats for Resque.
Stats are tracked per Job type (class/module) in addition to the worker based stats Resque provides.
Stats tracked are:
-
Jobs performed
-
Jobs enqueued
-
Jobs failed
-
Duration of last x jobs completed
-
Average job duration over last 100 jobs completed
-
Longest job duration over last 100 jobs completed
-
Jobs enqueued as timeseries data (minute, hourly)
-
Jobs performed as timeseries data (minute, hourly)
This information can be used to help track performance and diagnose specific bottlenecks.
We are sending this information to Nagios for graphing and alerts (via a custom rake task).
Requires resque ‘~> 1.17.0’
In your Gemfile add:
gem 'resque-job-stats'
Simply extend your class
class MyJob extend Resque::Plugins::JobStats @queue = :my_job def self.perform(*args) # .. end end
And you will have a set of keys starting with ‘stats:jobs:my_job’ inside your Resque redis namespace.
Alternatively you can include just the metric you wish to record.
class MyVerboseJob extend Resque::Plugins::JobStats::Performed extend Resque::Plugins::JobStats::Enqueued extend Resque::Plugins::JobStats::Failed extend Resque::Plugins::JobStats::Duration extend Resque::Plugins::JobStats::Timeseries::Enqueued extend Resque::Plugins::JobStats::Timeseries::Performed @queue = :my_job def self.perform(*args) # ... end end
The duration module provides two metrics, the longest job and the job rolling avg.
These are accessible via two singleton methods, MyJob.job_rolling_avg and MyJob.longest_job.
By default the last 100 jobs durations are stored and used to provide the above metrics.
You may set the number of jobs to include by setting the @durations_recorded variable.
class MyJob extend Resque::Plugins::JobStats::Duration @queue = :my_job @durations_recorded = 1000 def self.perform(*payload) # ... end end
The timeseries module provides timeseries counts of jobs performed. The metrics are rolling and kept for a period of time before being expired. The timestamp used for the timeseries data is UTC.
-
Add ui for stats in resque-web
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright © 2011 Alan Peabody. See LICENSE.txt for further details.