resque-analytics

Gem Version

Resque jobs analytics and key performance indicators over time

This gem keeps statistics per worker for the last 90 days, to be later shown as over time graphs. For each worker, the gem keeps the following key performance indicators:

Wait is somewhat tricky, as Resque doesn't provide the proper hooks to calculate this value. To handle that, I had to replace Resque's push method, and Job initialization method. These methods now add a timestamp when items are added to queues, and use the timestamp to calculate the total wait time, when an item is taken out of the queue.

Note that wait time calculation changes the Resque object that is placed in the queues. It means that code that relies on object's exact value will fail. A known conflict is with ts-resque-delta which deletes all queued jobs that have the same key. Adding a timestamp to each key, makes them unique, and conflicts with the keys deletion. See the usage section below for further details.

Installation

Requires resque '~> 1.25.1', and googlecharts '~> 1.6.8'

Add the following to your gemfile:

gem 'resque-analytics', require: 'resque-analytics/server'

Usage

Extend Resque workers with:

class Worker
  extend Resque::Plugins::Analytics

  @queue = :queue
  def self.perform(*args)
    # ..
  end
end

On the Resque screens, you will find a new tab called “Analytics”.

If you wish to stop collection wait time for certain classes, add the following to your resque.rb initializer: Resque::Plugins::Analytics.ignore_classes = ['worker_class', …]

where worker class represents a job class for which you do not want to collect wait time metrics.

TODO

Contributing to resque-analytics

Contributers

Copyright © 2014 Nir Tzur. See LICENSE for further details.