lib/elastic_apm/spies/sidekiq.rb in elastic-apm-3.15.1 vs lib/elastic_apm/spies/sidekiq.rb in elastic-apm-4.0.0.beta.1

- old
+ new

@@ -63,35 +63,33 @@ chain.add Middleware end end end - def install_processor - require 'sidekiq/processor' - - Sidekiq::Processor.class_eval do - alias start_without_apm start - alias terminate_without_apm terminate - - def start - result = start_without_apm - + # @api private + module Ext + def start + super.tap do # Already running from Railtie if Rails if ElasticAPM.running? ElasticAPM.agent.config.logger = Sidekiq.logger else ElasticAPM.start end - - result end + end - def terminate - terminate_without_apm - + def terminate + super.tap do ElasticAPM.stop end end + end + + def install_processor + require 'sidekiq/processor' + + Sidekiq::Processor.prepend(Ext) end def install install_processor install_middleware