Class: Rollbar::Sidekiq
- Inherits:
-
Object
- Object
- Rollbar::Sidekiq
- Defined in:
- lib/rollbar/plugins/sidekiq/plugin.rb
Defined Under Namespace
Classes: ResetScope
Constant Summary collapse
- PARAM_BLACKLIST =
%w[backtrace error_backtrace error_message error_class].freeze
Class Method Summary collapse
- .handle_exception(msg, e) ⇒ Object
- .job_scope(msg) ⇒ Object
- .scrub_params(params) ⇒ Object
- .skip_report?(msg, _e) ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.handle_exception(msg, e) ⇒ Object
17 18 19 20 21 |
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 17 def self.handle_exception(msg, e) return if skip_report?(msg, e) Rollbar.scope(job_scope(msg)).error(e, :use_exception_level_filters => true) end |
.job_scope(msg) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 34 def self.job_scope(msg) scope = { :framework => "Sidekiq: #{::Sidekiq::VERSION}" } job_hash = job_hash_from_msg(msg) unless job_hash.nil? params = job_hash.reject { |k| PARAM_BLACKLIST.include?(k) } scope[:request] = { :params => scrub_params(params) } scope[:context] = params['class'] scope[:queue] = params['queue'] end scope end |
.scrub_params(params) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 50 def self.scrub_params(params) = { :params => params, :config => Rollbar.configuration.scrub_fields, :whitelist => Rollbar.configuration.scrub_whitelist } Rollbar::Scrubbers::Params.call() end |
.skip_report?(msg, _e) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 23 def self.skip_report?(msg, _e) job_hash = job_hash_from_msg(msg) return false if job_hash.nil? # when rollbar middleware catches, sidekiq's retry_job processor hasn't set # the retry_count for the current job yet, so adding 1 gives the actual retry count actual_retry_count = job_hash.fetch('retry_count', -1) + 1 job_hash['retry'] && actual_retry_count < ::Rollbar.configuration.sidekiq_threshold end |
Instance Method Details
#call(_worker, msg, _queue, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rollbar/plugins/sidekiq/plugin.rb', line 61 def call(_worker, msg, _queue, &block) Rollbar.reset_notifier! # clears scope return yield unless Rollbar.configuration.sidekiq_use_scoped_block Rollbar.scoped(Rollbar::Sidekiq.job_scope(msg), &block) rescue Exception => e # rubocop:disable Lint/RescueException Rollbar::Sidekiq.handle_exception(msg, e) raise end |