LoggingWorker lets you create a record each time a background worker is run. It handles this automatically for you. There will be a new JobRun
model that contains each run.
Add logging_worker to your Gemfile
gem 'logging_worker', :github => 'smartlogic/logging_worker'
Bundle it!
$ bundle install
Install migrations
$ rake logging_worker_engine:install:migrations
Add to your workers.
class MyWorker
include Sidekiq::Worker
# Using prepend is VERY important
prepend LoggingWorker::Worker
# ...
end
Each time a background job is performed a new JobRun
will be created. JobRun
has the following attributes:
worker_class
worker class that performed the jobarguments
arguments used for running the jobsuccessful
if the job finished successfully, with no errorscompleted_at
when the job finished, regardless of success statuslog
Log of the joberror_message
if the job errored, the error messageerror_backtrace
if the job errored, the error backtrace