class Atatus::Spies::SuckerPunchSpy

@api private

Constants

TYPE

Public Instance Methods

__run_perform(*args) click to toggle source
# File lib/atatus/spies/sucker_punch.rb, line 33
def __run_perform(*args)
  # This method is reached via JobClass#async_perform
  # or JobClass#perform_in.
  name = to_s
  transaction = Atatus.start_transaction(name, TYPE)
  __run_perform_without_atatus(*args)
  transaction.done 'success'
rescue ::Exception => e
  # Note that SuckerPunch by default doesn't raise the errors from
  # the user-defined JobClass#perform method as it uses an error
  # handler, accessed via `SuckerPunch.exception_handler`.
  Atatus.report(e, handled: false)
  transaction.done 'error'
  raise
ensure
  Atatus.end_transaction
end
install() click to toggle source
# File lib/atatus/spies/sucker_punch.rb, line 27
def install
  if defined?(::SuckerPunch) && defined?(::SuckerPunch::Job) && defined?(::SuckerPunch::Job::ClassMethods)

    ::SuckerPunch::Job::ClassMethods.class_eval do
      alias :__run_perform_without_atatus :__run_perform

      def __run_perform(*args)
        # This method is reached via JobClass#async_perform
        # or JobClass#perform_in.
        name = to_s
        transaction = Atatus.start_transaction(name, TYPE)
        __run_perform_without_atatus(*args)
        transaction.done 'success'
      rescue ::Exception => e
        # Note that SuckerPunch by default doesn't raise the errors from
        # the user-defined JobClass#perform method as it uses an error
        # handler, accessed via `SuckerPunch.exception_handler`.
        Atatus.report(e, handled: false)
        transaction.done 'error'
        raise
      ensure
        Atatus.end_transaction
      end
    end

  end
end