Sha256: 8f5fff16f81e8b3eeef03dfb4f9ec80edc0fd40e7b6ff6cc29754eaefe5e68a1

Contents?: true

Size: 1.2 KB

Versions: 59

Compression:

Stored size: 1.2 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)
          class_and_method_name = if job.payload_object.respond_to?(:appsignal_name)
            job.payload_object.appsignal_name
          else
            job.name
          end
          class_name, method_name = class_and_method_name.split('#')

          Appsignal.monitor_transaction(
            'perform_job.delayed_job',
            :class    => class_name,
            :method   => method_name,
            :metadata => {
              :id       => job.id,
              :queue    => job.queue,
              :priority => job.priority || 0,
              :attempts => job.attempts || 0
            },
            :queue_start => job.created_at
          ) do
            block.call(job)
          end
        end
      end
    end
  end
  ::Delayed::Worker.plugins << Appsignal::Integrations::DelayedPlugin
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
appsignal-0.11.18 lib/appsignal/integrations/delayed_job.rb
appsignal-0.11.17 lib/appsignal/integrations/delayed_job.rb
appsignal-0.11.16 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.38 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.37 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.36 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.35 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.34 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.33 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.32 lib/appsignal/integrations/delayed_job.rb
appsignal-0.11.15 lib/appsignal/integrations/delayed_job.rb
appsignal-0.11.14 lib/appsignal/integrations/delayed_job.rb
appsignal-0.11.14.beta.1 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.31 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.30 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.29 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.28 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.27 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.26 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.25 lib/appsignal/integrations/delayed_job.rb