Sha256: a4bc60a11d493887614f2ea211ca47b8649a9dbb859248dca4537aa4cd038e55

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

if defined?(::Resque)
  Appsignal.logger.info('Loading Resque integration')

  module Appsignal
    module Integrations
      module ResquePlugin

        def around_perform_resque_plugin(*args)
          Appsignal::Transaction.create(SecureRandom.uuid, ENV)
          ActiveSupport::Notifications.instrument(
            'perform_job.resque',
            :class => self.to_s,
            :method => 'perform'
          ) do
            yield
          end
        rescue Exception => exception
          unless Appsignal.is_ignored_exception?(exception)
            Appsignal::Transaction.current.add_exception(exception)
          end
          raise exception
        ensure
          Appsignal::Transaction.current.complete!
        end

      end
    end
  end

  # Create a pipe for the workers to write to
  Resque.before_first_fork do
    Appsignal::Pipe.init
  end

  # In the fork, stop the normal agent startup
  # and stop listening to the pipe (we'll only use it for writing)
  Resque.after_fork do |job|
    Appsignal.agent.stop_thread
    Appsignal::Pipe.current.stop_listening!
  end

  # Extend the default job class with AppSignal instrumentation
  Resque::Job.send(:extend, Appsignal::Integrations::ResquePlugin)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
appsignal-0.8.15 lib/appsignal/integrations/resque.rb
appsignal-0.8.14 lib/appsignal/integrations/resque.rb
appsignal-0.8.13 lib/appsignal/integrations/resque.rb
appsignal-0.8.12 lib/appsignal/integrations/resque.rb
appsignal-0.8.11 lib/appsignal/integrations/resque.rb
appsignal-0.8.10 lib/appsignal/integrations/resque.rb
appsignal-0.8.8 lib/appsignal/integrations/resque.rb
appsignal-0.8.7 lib/appsignal/integrations/resque.rb
appsignal-0.8.7.alpha.1 lib/appsignal/integrations/resque.rb
appsignal-0.8.6 lib/appsignal/integrations/resque.rb