rollbar/rollbar-gem — pull request #116 by notahat (2014-06-05 05:04:58+00:00)
Title: This should fix #115

The method used to install Rollbar's Delayed Job hook is taken from this Stack Overflow answer:

http://stackoverflow.com/questions/12683364/how-to-make-delayed-job-notify-airbrake-when-an-actionmailer-runs-into-an-error/14172132#14172132

Unfortunately, the answer has a flaw. Delayed Job plugins can be run more than once (specifically whenever a Delayed::Worker is instantiated, which can happen multiple times in testing), and the plugin will install another copy of the hook each time. This leads to giant stacktraces full of multiple copies of the same block.

The correct approach is to simply install the hook directly, once, at load time.