Sha256: 94314d448b7e9c6d704435a90c2ff20b860a27cd29efcf534828e9168f86755b

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

module Sentry
  module Sidekiq
    class SentryContextMiddleware
      def call(_worker, job, queue)
        return yield unless Sentry.initialized?

        Sentry.clone_hub_to_current_thread
        scope = Sentry.get_current_scope
        scope.set_extras(sidekiq: job.merge("queue" => queue))
        scope.set_transaction_name("Sidekiq/#{job["class"]}")

        yield

        # don't need to use ensure here
        # if the job failed, we need to keep the scope for error handler. and the scope will be cleared there
        scope.clear
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-sidekiq-4.1.3 lib/sentry/sidekiq/sentry_context_middleware.rb
sentry-sidekiq-4.1.2 lib/sentry/sidekiq/sentry_context_middleware.rb