class StackifyRubyAPM::Spies::DelayedJobSpy
@api private
Public Instance Methods
install()
click to toggle source
# File lib/stackify_apm/spies/delayed_job.rb, line 11 def install Delayed::Backend::Base.class_eval do alias_method 'invoke_job_without_apm', 'invoke_job' def invoke_job(*args, &block) ret = nil begin name = nil if payload_object.is_a?(::Delayed::PerformableMethod) object = payload_object.object klass = object.is_a?(Class) ? object : object.class class_name = klass.name separator = payload_object.object.is_a?(Class) ? '.' : '#' method_name = payload_object.method_name name = "#{class_name}#{separator}#{method_name}" else name = payload_object.class.name end ctx = StackifyRubyAPM::Context.new ctx.category = 'Delayed::Job' transaction = StackifyRubyAPM.transaction name, 'TASK', context: ctx ret = invoke_job_without_apm(*args, &block) rescue StackifyRubyAPM::InternalError raise # Don't report StackifyRubyAPM errors rescue StandardError => e StackifyRubyAPM.report e raise e ensure transaction.submit() end ret end end end
invoke_job(*args, &block)
click to toggle source
# File lib/stackify_apm/spies/delayed_job.rb, line 15 def invoke_job(*args, &block) ret = nil begin name = nil if payload_object.is_a?(::Delayed::PerformableMethod) object = payload_object.object klass = object.is_a?(Class) ? object : object.class class_name = klass.name separator = payload_object.object.is_a?(Class) ? '.' : '#' method_name = payload_object.method_name name = "#{class_name}#{separator}#{method_name}" else name = payload_object.class.name end ctx = StackifyRubyAPM::Context.new ctx.category = 'Delayed::Job' transaction = StackifyRubyAPM.transaction name, 'TASK', context: ctx ret = invoke_job_without_apm(*args, &block) rescue StackifyRubyAPM::InternalError raise # Don't report StackifyRubyAPM errors rescue StandardError => e StackifyRubyAPM.report e raise e ensure transaction.submit() end ret end