Skip to content

Commit

Permalink
Add solid queue support
Browse files Browse the repository at this point in the history
Based entirely on GoodJob integration at this point.
  • Loading branch information
lancetarn committed Sep 9, 2024
1 parent efc5cbc commit f993a8e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/scout_apm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module ScoutApm
require 'scout_apm/background_job_integrations/que'
require 'scout_apm/background_job_integrations/legacy_sneakers'
require 'scout_apm/background_job_integrations/good_job'
require 'scout_apm/background_job_integrations/solid_queue'

require 'scout_apm/framework_integrations/rails_2'
require 'scout_apm/framework_integrations/rails_3_or_4'
Expand Down
47 changes: 47 additions & 0 deletions lib/scout_apm/background_job_integrations/solid_queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module ScoutApm
module BackgroundJobIntegrations
class SolidQueue
UNKNOWN_QUEUE_PLACEHOLDER = 'default'.freeze
attr_reader :logger

def name
:solid_queue
end

def present?
defined?(::SolidQueue::VERSION)
end

def forking?
false
end

def install
ActiveSupport.on_load(:active_job) do
include ScoutApm::Tracer

around_perform do |job, block|
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
end
end
end
1 change: 1 addition & 0 deletions lib/scout_apm/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Environment
ScoutApm::BackgroundJobIntegrations::Que.new,
ScoutApm::BackgroundJobIntegrations::Faktory.new,
ScoutApm::BackgroundJobIntegrations::GoodJob.new,
ScoutApm::BackgroundJobIntegrations::SolidQueue.new,
]

FRAMEWORK_INTEGRATIONS = [
Expand Down

0 comments on commit f993a8e

Please sign in to comment.