Method: ElasticAPM::Spies::SuckerPunchSpy#install
- Defined in:
- lib/elastic_apm/spies/sucker_punch.rb
#install ⇒ Object
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/elastic_apm/spies/sucker_punch.rb', line 27 def install ::SuckerPunch::Job::ClassMethods.class_eval do alias :__run_perform_without_elastic_apm :__run_perform def __run_perform(*args) # This method is reached via JobClass#async_perform # or JobClass#perform_in. name = to_s transaction = ElasticAPM.start_transaction(name, TYPE) __run_perform_without_elastic_apm(*args) transaction.done 'success' transaction&.outcome = Transaction::Outcome::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`. ElasticAPM.report(e, handled: false) transaction.done 'error' transaction&.outcome = Transaction::Outcome::FAILURE raise ensure ElasticAPM.end_transaction end end end |