Sha256: b08a28343513711393f4ed94e62215fcf9eb47090358438698922755ab77acad

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

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(msg_or_context, e)
      return if skip_report?(msg_or_context, e)

      params = msg_or_context.reject{ |k| PARAM_BLACKLIST.include?(k) }
      scope = {
        :request => { :params => 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

    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

    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

6 entries across 6 versions & 1 rubygems

Version Path
rollbar-2.11.5 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.11.4 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.11.3 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.11.2 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.11.1 lib/rollbar/plugins/sidekiq/plugin.rb
rollbar-2.11.0 lib/rollbar/plugins/sidekiq/plugin.rb