Sha256: 14016bdbff62c8963f1ea16f6410817c7ea876713311ad0be11c590597f6cb1a

Contents?: true

Size: 907 Bytes

Versions: 12

Compression:

Stored size: 907 Bytes

Contents

require 'sentry/sidekiq/context_filter'

module Sentry
  module Sidekiq
    class ErrorHandler
      def call(ex, context)
        return unless Sentry.initialized?

        context_filter = Sentry::Sidekiq::ContextFilter.new(context)

        scope = Sentry.get_current_scope
        scope.set_transaction_name(context_filter.transaction_name) unless scope.transaction_name

        retry_option = context.dig(:job, "retry")

        if Sentry.configuration.sidekiq.report_after_job_retries && retry_option.is_a?(Integer) && retry_option.positive?
          retry_count = context.dig(:job, "retry_count")
          if retry_count.nil? || retry_count < retry_option - 1
            return
          end
        end

        Sentry::Sidekiq.capture_exception(
          ex,
          contexts: { sidekiq: context_filter.filtered },
          hint: { background: false }
        )
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sentry-sidekiq-5.0.1 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-5.0.0 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.9.2 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.9.1 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.9.0 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.8.3 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.8.2 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.8.1 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.8.0 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.7.3 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.7.2 lib/sentry/sidekiq/error_handler.rb
sentry-sidekiq-4.7.1 lib/sentry/sidekiq/error_handler.rb