Module: ScoutApm::BackgroundJobIntegrations::LegacySneakers
- Defined in:
- lib/scout_apm/background_job_integrations/legacy_sneakers.rb
Constant Summary collapse
- UNKNOWN_QUEUE_PLACEHOLDER =
'default'.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#initialize(*args) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/scout_apm/background_job_integrations/legacy_sneakers.rb', line 20 def initialize(*args) super # Save off the existing value to call the correct existing work # function in the instrumentation. But then override Sneakers to always # use the extra-argument version, which has data Scout needs @call_work = respond_to?(:work) end |
#work_with_params(msg, delivery_info, metadata) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/scout_apm/background_job_integrations/legacy_sneakers.rb', line 29 def work_with_params(msg, delivery_info, ) queue = delivery_info[:routing_key] || UNKNOWN_QUEUE_PLACEHOLDER job_class = self.class.name req = ScoutApm::RequestManager.lookup begin req.start_layer(ScoutApm::Layer.new('Queue', queue)) started_queue = true req.start_layer(ScoutApm::Layer.new('Job', job_class)) started_job = true if @call_work work(msg) else super end rescue Exception req.error! raise ensure req.stop_layer if started_job req.stop_layer if started_queue end end |