Class: Skylight::Core::Probes::ActiveJob::EnqueueProbe Private
- Inherits:
-
Object
- Object
- Skylight::Core::Probes::ActiveJob::EnqueueProbe
- Defined in:
- lib/skylight/core/probes/active_job_enqueue.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- CAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"other.active_job.enqueue".freeze
Instance Method Summary collapse
- #install ⇒ Object private
Instance Method Details
#install ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/skylight/core/probes/active_job_enqueue.rb', line 7 def install ::ActiveJob::Base.around_enqueue do |job, block| begin job_class = job.class adapter_name = EnqueueProbe.normalize_adapter_name(job_class) # If this is an ActionMailer::DeliveryJob, we'll report this as the mailer title # and include ActionMailer::DeliveryJob in the description. name, job_class_name = Skylight::Core::Normalizers::ActiveJob::Perform.normalize_title(job) descriptors = ["adapter: '#{adapter_name}'", "queue: '#{job.queue_name}'"] descriptors << "job: '#{job_class_name}'" if job_class_name desc = "{ #{descriptors.join(', ')} }" rescue block.call else Skylight::Core::Fanout.instrument( title: "Enqueue #{name}", category: CAT, description: desc, &block ) end end self.class.instance_eval do if ::ActiveJob.gem_version >= Gem::Version.new("5.2") def normalize_adapter_name(job_class) job_class.queue_adapter_name end else def normalize_adapter_name(job_class) adapter_class = job_class.queue_adapter.is_a?(Class) ? job_class.queue_adapter : job_class.queue_adapter.class adapter_class.name.demodulize.remove("Adapter").underscore end end end end |