Sha256: 7c0ad8532d63d90c3558ccd9776f8726d9c7127dca961915cdaa999c1594f652

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

require 'rollbar/scrubbers/params'

module Rollbar
  class Sidekiq
    PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class]

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

        yield
      end
    end

    def self.handle_exception(ctx_hash, e)
      job_hash = ctx_hash && (ctx_hash[:job] || ctx_hash)
      return if skip_report?(job_hash, e)

      scope = {
        :framework => "Sidekiq: #{::Sidekiq::VERSION}"
      }
      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

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

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

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

    def self.skip_report?(job_hash, e)
      !job_hash.nil? && (job_hash['retry'] && job_hash['retry_count'] &&
        job_hash['retry_count'] < ::Rollbar.configuration.sidekiq_threshold)
    end

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rollbar-2.16.4 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.16.3 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.16.2 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.16.0 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.6 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.5 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.4 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.3 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.2 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.15.1 lib/rollbar/plugins/sidekiq/plugin.rb