Class: Rollbar::Sidekiq

Inherits:
Object
  • Object
show all
Defined in:
lib/rollbar/plugins/sidekiq/plugin.rb

Defined Under Namespace

Classes: ClearScope

Constant Summary collapse

PARAM_BLACKLIST =
%w[backtrace error_backtrace error_message error_class]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handle_exception(msg_or_context, e) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 15

def self.handle_exception(msg_or_context, e)
  return if skip_report?(msg_or_context, e)

  params = msg_or_context.reject{ |k| PARAM_BLACKLIST.include?(k) }
  scrubbed_params = scrub_params(params)
  scope = {
    :request => { :params => scrubbed_params },
    :framework => "Sidekiq: #{::Sidekiq::VERSION}"
  }
  if params.is_a?(Hash)
    scope[:context] = params['class']
    scope[:queue] = params['queue']
  end

  Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
end

.scrub_params(params) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 32

def self.scrub_params(params)
  options = {
    :params => params,
    :config => Rollbar.configuration.scrub_fields
  }

  Rollbar::Scrubbers::Params.call(options)
end

.skip_report?(msg_or_context, e) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 41

def self.skip_report?(msg_or_context, e)
  msg_or_context.is_a?(Hash) && msg_or_context["retry"] &&
    msg_or_context["retry_count"] && msg_or_context["retry_count"] < ::Rollbar.configuration.sidekiq_threshold
end

Instance Method Details

#call(worker, msg, queue) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 46

def call(worker, msg, queue)
  Rollbar.reset_notifier!

  yield
rescue Exception => e
  Rollbar::Sidekiq.handle_exception(msg, e)
  raise
end