Sha256: 5f6c128f70109332989e778f8ae168556ce0c92eabb01d40cc8905d1319bbf52

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.

require_relative 'resque/instrumentation'
require_relative 'resque/chain'
require_relative 'resque/prepend'

DependencyDetection.defer do
  @name = :resque

  depends_on do
    defined?(::Resque::Job) && !NewRelic::Agent.config[:disable_resque]
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing Resque instrumentation'
  end

  executes do
    if NewRelic::Agent.config[:'resque.use_ruby_dns'] && NewRelic::Agent.config[:dispatcher] == :resque
      ::NewRelic::Agent.logger.info 'Requiring resolv-replace'
      require 'resolv'
      require 'resolv-replace'
    end
  end

  executes do
    if use_prepend?
      prepend_instrument ::Resque::Job, NewRelic::Agent::Instrumentation::Resque::Prepend
    else
      chain_instrument NewRelic::Agent::Instrumentation::Resque::Chain
    end

    if NewRelic::LanguageSupport.can_fork?
      ::Resque.before_first_fork do
        NewRelic::Agent.manual_start(:dispatcher   => :resque,
                                     :sync_startup => true,
                                     :start_channel_listener => true)
      end

      ::Resque.before_fork do |job|
        if ENV['FORK_PER_JOB'] != 'false'
          NewRelic::Agent.register_report_channel(job.object_id)
        end
      end

      ::Resque.after_fork do |job|
        # Only suppress reporting Instance/Busy for forked children
        # Traced errors UI relies on having the parent process report that metric
        NewRelic::Agent.after_fork(:report_to_channel => job.object_id,
                                   :report_instance_busy => false)
      end
    end
  end
end

# call this now so it is memoized before potentially forking worker processes
NewRelic::LanguageSupport.can_fork?

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newrelic_rpm-7.0.0 lib/new_relic/agent/instrumentation/resque.rb