Sha256: 16b8c0698130d8046b01d3f03a38e488c9bcd4d1e45bf7e388a0113ae2b07d39

Contents?: true

Size: 1.28 KB

Versions: 19

Compression:

Stored size: 1.28 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

          lifecycle.after(:loop) do |loop|
            Appsignal.stop
          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

19 entries across 19 versions & 1 rubygems

Version Path
appsignal-0.12.rc.7 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.rc.6 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.rc.5 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.54 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.53 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.52 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.51 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.50 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.49 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.48 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.47 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.46 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.45 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.44 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.43 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.42 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.41 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.40 lib/appsignal/integrations/delayed_job.rb
appsignal-0.12.beta.39 lib/appsignal/integrations/delayed_job.rb