Class: Instana::Activators::ResqueWorker

Inherits:
Instana::Activator show all
Defined in:
lib/instana/activators/resque_worker.rb

Instance Method Summary collapse

Methods inherited from Instana::Activator

#call, call, inherited, start

Instance Method Details

#can_instrument?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
# File 'lib/instana/activators/resque_worker.rb', line 7

def can_instrument?
  defined?(::Resque::Worker) &&
    defined?(::Resque::Job) &&
    ::Instana.config[:'resque-worker'][:enabled]
end

#instrumentObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/instana/activators/resque_worker.rb', line 13

def instrument
  require 'instana/instrumentation/resque'

  ::Resque::Worker.prepend(::Instana::Instrumentation::ResqueWorker)
  ::Resque::Job.prepend(::Instana::Instrumentation::ResqueJob)

  if ::Instana.config[:'resque-worker'][:'setup-fork']
    ::Resque.after_fork do |_job|
      ::Instana.agent.after_fork
    end
  end

  # Set this so we assure that any remaining collected traces are reported at_exit
  ENV['RUN_AT_EXIT_HOOKS'] = "1"

  true
end