Sha256: 9fdcd08b52659bafc9e54a67d1408abda99fa42c3d302be00eb567e1468886ea
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
module Appsignal class Hooks # @api private class DelayedJobPlugin < ::Delayed::Plugin extend Appsignal::Hooks::Helpers callbacks do |lifecycle| lifecycle.around(:invoke_job) do |job, &block| invoke_with_instrumentation(job, block) end lifecycle.after(:execute) do |_execute| Appsignal.stop("delayed job") end end def self.invoke_with_instrumentation(job, block) if job.respond_to?(:payload_object) # Direct Delayed Job class_and_method_name = extract_value(job.payload_object, :appsignal_name, job.name) class_name, method_name = class_and_method_name.split("#") args = extract_value(job.payload_object, :args, {}) job_data = job elsif job.respond_to?(:job_data) # Via ActiveJob class_name, method_name = job.job_data[:name].split("#") args = job.job_data[:args] || {} job_data = job.job_data else args = {} end params = Appsignal::Utils::ParamsSanitizer.sanitize args, :filter_parameters => Appsignal.config[:filter_parameters] Appsignal.monitor_transaction( "perform_job.delayed_job", :class => class_name, :method => method_name, :metadata => { :id => extract_value(job_data, :id, nil, true), :queue => extract_value(job_data, :queue), :priority => extract_value(job_data, :priority, 0), :attempts => extract_value(job_data, :attempts, 0) }, :params => params, :queue_start => extract_value(job_data, :created_at) ) do block.call(job) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appsignal-2.3.0.beta.1 | lib/appsignal/integrations/delayed_job_plugin.rb |