Sha256: f851b8f8adde5530fd649277e5de7c70c5afc0ff4cfa7ec6657343363d572fdc

Contents?: true

Size: 1.22 KB

Versions: 9

Compression:

Stored size: 1.22 KB

Contents

if defined?(::Delayed::Plugin)
  Appsignal.logger.info('Loading Delayed Job integration')

  module Appsignal
    module Integrations
      class DelayedPlugin < ::Delayed::Plugin
        callbacks do |lifecycle|
          lifecycle.around(:invoke_job) do |job, &block|
            invoke_with_instrumentation(job, block)
          end
        end

        def self.invoke_with_instrumentation(job, block)
          begin
            Appsignal::Transaction.create(SecureRandom.uuid, ENV)
            class_name, method_name = job.name.split('#')
            ActiveSupport::Notifications.instrument(
              'perform_job.delayed_job',
              :class => class_name,
              :method => method_name,
              :priority => job.priority,
              :attempts => job.attempts,
              :queue => job.queue,
              :queue_start => job.created_at
            ) do
              block.call(job)
            end
          rescue Exception => exception
            Appsignal.add_exception(exception)
            raise exception
          ensure
            Appsignal::Transaction.complete_current!
          end
        end
      end
    end
  end
  ::Delayed::Worker.plugins << Appsignal::Integrations::DelayedPlugin
end

Version data entries

9 entries across 9 versions & 1 rubygems

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