lib/sentry/sidekiq/error_handler.rb in sentry-sidekiq-4.1.3 vs lib/sentry/sidekiq/error_handler.rb in sentry-sidekiq-4.2.0

- old
+ new

@@ -1,39 +1,22 @@ require 'sentry/sidekiq/context_filter' module Sentry module Sidekiq class ErrorHandler - SIDEKIQ_NAME = "Sidekiq".freeze - def call(ex, context) return unless Sentry.initialized? - context = Sentry::Sidekiq::ContextFilter.new.filter_context(context) + + context_filter = Sentry::Sidekiq::ContextFilter.new(context) + scope = Sentry.get_current_scope - scope.set_transaction_name(transaction_from_context(context)) unless scope.transaction_name + scope.set_transaction_name(context_filter.transaction_name) unless scope.transaction_name Sentry::Sidekiq.capture_exception( ex, - extra: { sidekiq: context }, + extra: { sidekiq: context_filter.filtered }, hint: { background: false } ) - end - - private - - # this will change in the future: - # https://github.com/mperham/sidekiq/pull/3161 - def transaction_from_context(context) - classname = (context["wrapped"] || context["class"] || - (context[:job] && (context[:job]["wrapped"] || context[:job]["class"])) - ) - if classname - "#{SIDEKIQ_NAME}/#{classname}" - elsif context[:event] - "#{SIDEKIQ_NAME}/#{context[:event]}" - else - SIDEKIQ_NAME - end end end end end