Sha256: c8e33110deb0361a788f8cab78ee84c04ae1c01266919b8258f5a2e177923710

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

require 'new_relic/agent/instrumentation/controller_instrumentation'

DependencyDetection.defer do
  @name = :delayed_job
  
  depends_on do
    !NewRelic::Agent.config[:disable_dj]
  end

  depends_on do
    # double check because of old JRuby bug 
    defined?(::Delayed) && defined?(::Delayed::Job) &&
      Delayed::Job.method_defined?(:invoke_job)
  end
  
  executes do
    ::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation'
  end
  
  executes do
    Delayed::Job.class_eval do
      include NewRelic::Agent::Instrumentation::ControllerInstrumentation
      if self.instance_methods.include?('name') || self.instance_methods.include?(:name)
        add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}'
      else
        add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob'
      end
    end
  end

  executes do
    Delayed::Job.instance_eval do
      if self.respond_to?('after_fork')
        if method_defined?(:after_fork)
          def after_fork_with_newrelic
            NewRelic::Agent.after_fork(:force_reconnect => true)
            after_fork_without_newrelic
          end

          alias_method :after_fork_without_newrelic, :after_fork
          alias_method :after_fork, :after_fork_with_newrelic
        else
          def after_fork
            NewRelic::Agent.after_fork(:force_reconnect => true)
            super
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
wd_newrelic_rpm-3.5.8 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
sundawg_newrelic_rpm-3.5.8.2 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
sundawg_newrelic_rpm-3.5.8.1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.8.72 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.8.70 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.8.64.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.7.59 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.7.59.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.7.58.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
wd_newrelic_rpm-3.5.6 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.7.57.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.6.55 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.6.48.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.6.46.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.6.42.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.5.39.beta lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
wd_newrelic_rpm-3.5.5 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.5.38 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.5.5.540.dev lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb