Sha256: 16688eac0a8e79b65196165fed23bbb2f6047d3f966e18770ea2b4deff9a89f3

Contents?: true

Size: 880 Bytes

Versions: 15

Compression:

Stored size: 880 Bytes

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

module Instana
  module Activators
    class ResqueWorker < Activator
      def can_instrument?
        defined?(::Resque::Worker) &&
          defined?(::Resque::Job) &&
          ::Instana.config[:'resque-worker'][:enabled]
      end

      def instrument
        require 'instana/instrumentation/resque'

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

        ::Resque.before_fork do |_job|
          ::Instana.agent.before_resque_fork
        end
        ::Resque.after_fork do |_job|
          ::Instana.agent.after_resque_fork
        end

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

        true
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
instana-1.199.2 lib/instana/activators/resque_worker.rb
instana-1.199.1 lib/instana/activators/resque_worker.rb
instana-1.199.0 lib/instana/activators/resque_worker.rb
instana-1.198.0 lib/instana/activators/resque_worker.rb
instana-1.198.0.pre1 lib/instana/activators/resque_worker.rb
instana-1.197.0 lib/instana/activators/resque_worker.rb
instana-1.197.0.pre2 lib/instana/activators/resque_worker.rb
instana-1.197.0.pre1 lib/instana/activators/resque_worker.rb
instana-1.195.4 lib/instana/activators/resque_worker.rb
instana-1.195.3 lib/instana/activators/resque_worker.rb
instana-1.195.2 lib/instana/activators/resque_worker.rb
instana-1.195.1 lib/instana/activators/resque_worker.rb
instana-1.195.0 lib/instana/activators/resque_worker.rb
instana-1.193.6 lib/instana/activators/resque_worker.rb
instana-1.193.5 lib/instana/activators/resque_worker.rb