Module: Datadog::Contrib::Resque::ResqueJob

Defined in:
lib/ddtrace/contrib/resque/resque_job.rb

Overview

Uses Resque job hooks to create traces

Instance Method Summary collapse

Instance Method Details

#after_perform_shutdown_tracer(*_) ⇒ Object



26
27
28
# File 'lib/ddtrace/contrib/resque/resque_job.rb', line 26

def after_perform_shutdown_tracer(*_)
  shutdown_tracer_when_forked!
end

#around_perform(*_) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ddtrace/contrib/resque/resque_job.rb', line 12

def around_perform(*_)
  return yield unless datadog_configuration && tracer

  tracer.trace(Ext::SPAN_JOB, span_options) do |span|
    span.resource = name
    span.span_type = Datadog::Ext::AppTypes::WORKER
    # Set analytics sample rate
    if Contrib::Analytics.enabled?(datadog_configuration[:analytics_enabled])
      Contrib::Analytics.set_sample_rate(span, datadog_configuration[:analytics_sample_rate])
    end
    yield
  end
end

#on_failure_shutdown_tracer(*_) ⇒ Object



30
31
32
# File 'lib/ddtrace/contrib/resque/resque_job.rb', line 30

def on_failure_shutdown_tracer(*_)
  shutdown_tracer_when_forked!
end

#shutdown_tracer_when_forked!Object



34
35
36
# File 'lib/ddtrace/contrib/resque/resque_job.rb', line 34

def shutdown_tracer_when_forked!
  tracer.shutdown! if forked?
end