class ScoutApm::BackgroundJobIntegrations::GoodJob
Constants
- UNKNOWN_QUEUE_PLACEHOLDER
Attributes
Public Instance Methods
Source
# File lib/scout_apm/background_job_integrations/good_job.rb, line 15 def forking? false end
Source
# File lib/scout_apm/background_job_integrations/good_job.rb, line 19 def install ActiveSupport.on_load(:active_job) do include ScoutApm::Tracer around_perform do |job, block| # I have a sneaking suspicion there is a better way to handle Agent starting # Maybe hook into GoodJob lifecycle events? req = ScoutApm::RequestManager.lookup latency = Time.now - (job.scheduled_at || job.enqueued_at) rescue 0 req.annotate_request(queue_latency: latency) begin req.start_layer ScoutApm::Layer.new("Queue", job.queue_name.presence || UNKNOWN_QUEUE_PLACEHOLDER) started_queue = true # Following Convention req.start_layer ScoutApm::Layer.new("Job", job.class.name) started_job = true # Following Convention block.call rescue req.error! raise ensure req.stop_layer if started_job req.stop_layer if started_queue end end end end
Source
# File lib/scout_apm/background_job_integrations/good_job.rb, line 7 def name :good_job end
Source
# File lib/scout_apm/background_job_integrations/good_job.rb, line 11 def present? defined?(::GoodJob::VERSION) end