class Airbrake::Sidekiq::ErrorHandler
Provides integration with Sidekiq
v2+.
Public Instance Methods
call(_worker, context, _queue, &block)
click to toggle source
# File lib/airbrake/sidekiq.rb, line 9 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
Private Instance Methods
action(context)
click to toggle source
@return [String] job’s name. When ActiveJob is present, retrieve
job_class. When used directly, use worker's name
# File lib/airbrake/sidekiq.rb, line 38 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
notify_airbrake(exception, context)
click to toggle source
# File lib/airbrake/sidekiq.rb, line 29 def notify_airbrake(exception, context) Airbrake.notify(exception, job: context) do |notice| notice[:context][:component] = 'sidekiq' notice[:context][:action] = action(context) end end