Sha256: b8dd9ac9d915a63c779bf46b47441cc668aa1df9abf68bf8b729a88742bc0df7

Contents?: true

Size: 1.21 KB

Versions: 2

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.to_hash)
          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

2 entries across 2 versions & 1 rubygems

Version Path
appsignal-0.8.6.beta.1 lib/appsignal/integrations/resque.rb
appsignal-0.8.6.beta.0 lib/appsignal/integrations/resque.rb