Class: Skylight::Core::Probes::DelayedJob::Probe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/skylight/core/probes/delayed_job.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

UNKNOWN =

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.

"<Delayed::Job Unknown>".freeze

Instance Method Summary collapse

Instance Method Details

#installObject

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
# File 'lib/skylight/core/probes/delayed_job.rb', line 7

def install
  return unless validate_version
  ::Delayed::Worker.class_eval do
    include Skylight::Core::Util::Logging
    alias_method :run_without_sk, :run
    alias_method :handle_failed_job_without_sk, :handle_failed_job

    def run(job, *args)
      t { "Delayed::Job beginning trace" }

      handler_name = begin
        if defined?(::Delayed::PerformableMethod) && job.payload_object.is_a?(::Delayed::PerformableMethod)
          job.name
        else
          job.payload_object.class.name
        end
      rescue
        UNKNOWN
      end

      Skylight.trace(handler_name, "app.delayed_job.worker", "Delayed::Worker#run", segment: job.queue) do
        run_without_sk(job, *args)
      end
    end

    def handle_failed_job(job, error, *args)
      handle_failed_job_without_sk(job, error, *args)
      return unless Skylight.trace
      Skylight.trace.segment = "error"
    end
  end
end