class Airbrake::Sidekiq::ErrorHandler
Provides integration with Sidekiq v2+.
def action(context)
-
(String)
- job's name. When ActiveJob is present, retrieve
def action(context) klass = context['class'] || (context[:job] && context[:job]['class']) return klass unless context[:job] && context[:job]['args'].first.is_a?(Hash) return klass unless (job_class = context[:job]['args'].first['job_class']) job_class end
def call(_worker, context, _queue, &block)
def call(_worker, context, _queue, &block) timing = Airbrake::Benchmark.measure(&block) rescue Exception => exception # rubocop:disable Lint/RescueException notify_airbrake(exception, context) Airbrake.notify_queue( queue: context['class'], error_count: 1, timing: 0.01, ) raise exception else Airbrake.notify_queue( queue: context['class'], error_count: 0, timing: timing, ) end
def notify_airbrake(exception, context)
def notify_airbrake(exception, context) Airbrake.notify(exception, job: context) do |notice| notice[:context][:component] = 'sidekiq' notice[:context][:action] = action(context) end end