Sha256: 14643e312c8b439ae77d9f53bd371a2eb528857ee3e16f82cf832eb6b987d808

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 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
          Appsignal.add_exception(exception)
          raise exception
        ensure
          Appsignal::Transaction.complete_current!
        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

9 entries across 9 versions & 1 rubygems

Version Path
appsignal-0.9.6 lib/appsignal/integrations/resque.rb
appsignal-0.9.5 lib/appsignal/integrations/resque.rb
appsignal-0.9.4 lib/appsignal/integrations/resque.rb
appsignal-0.9.3 lib/appsignal/integrations/resque.rb
appsignal-0.9.2 lib/appsignal/integrations/resque.rb
appsignal-0.9.1 lib/appsignal/integrations/resque.rb
appsignal-0.9.0 lib/appsignal/integrations/resque.rb
appsignal-0.9.0.beta.1 lib/appsignal/integrations/resque.rb
appsignal-0.9.0.alpha.1 lib/appsignal/integrations/resque.rb