Skip to content

Instantly share code, notes, and snippets.

@joshuap
Created March 19, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuap/020e86fbfcda0f36f3b00c8013ff04ef to your computer and use it in GitHub Desktop.
Save joshuap/020e86fbfcda0f36f3b00c8013ff04ef to your computer and use it in GitHub Desktop.
Report ActiveJob exceptions to Honeybadger (default backend/unsupported backends)
# app/jobs/application_job.rb
class ApplicationJob < ActiveJob::Base
include HoneybadgerActiveJob
end
# config/initializers/honeybadger.rb
module HoneybadgerActiveJob
def self.included(base)
# See https://edgeguides.rubyonrails.org/active_job_basics.html#exceptions
base.send :rescue_from, StandardError do |exception|
Honeybadger.notify(exception, context: {
job: self.class.name,
job_id: job_id,
arguments: arguments
})
raise exception
end
end
end
# Report errors in ActionMailer jobs
ActionMailer::DeliveryJob.send(:include, HoneybadgerActiveJob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment