Class: Atatus::Spies::ResqueSpy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/atatus/spies/resque.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Resque'

Instance Method Summary collapse

Instance Method Details

#installObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/atatus/spies/resque.rb', line 27

def install
  install_perform_spy
end

#install_perform_spyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/atatus/spies/resque.rb', line 31

def install_perform_spy
  if defined?(::Resque) && defined?(::Resque::Job)

    ::Resque::Job.class_eval do
      alias :perform_without_atatus :perform

      def perform
        name = @payload && @payload['class']&.to_s
        transaction = Atatus.start_transaction(name, TYPE)
        perform_without_atatus
        transaction.done 'success'
      rescue ::Exception => e
        Atatus.report(e, handled: false)
        transaction.done 'error' if transaction
        raise
      ensure
        Atatus.end_transaction
      end
    end

  end
end