Module: NewRelic::Agent::Instrumentation::DelayedJob

Included in:
Prepend
Defined in:
lib/new_relic/agent/instrumentation/delayed_job/chain.rb,
lib/new_relic/agent/instrumentation/delayed_job/prepend.rb,
lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb,
lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb

Defined Under Namespace

Modules: Chain, Naming, Prepend

Instance Method Summary collapse

Instance Method Details

#initialize_with_tracingObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb', line 9

def initialize_with_tracing
  yield
  worker_name = case
                when self.respond_to?(:name) then self.name
                when self.class.respond_to?(:default_name) then self.class.default_name
  end
  NewRelic::DelayedJobInjection.worker_name = worker_name

  # TODO: Refactor the last line of this condition so that it can be evaluated in both prepend and chain instrumentation
  if defined?(::Delayed::Job) && ::Delayed::Job.method_defined?(:invoke_job) &&
      !(::Delayed::Job.method_defined?(:invoke_job_without_new_relic))

    ::NewRelic::Agent.logger.info('Installing DelayedJob instrumentation [part 2/2]')
    install_newrelic_job_tracer
    NewRelic::Control.instance.init_plugin(:dispatcher => :delayed_job)
  else
    NewRelic::Agent.logger.warn('Did not find a Delayed::Job class responding to invoke_job, aborting DJ instrumentation')
  end
end