Sha256: a4750fca1d5ccdbf050ba39b791bd7c6cd4a26a54af83fb449685fc23f7a9e89

Contents?: true

Size: 1.46 KB

Versions: 43

Compression:

Stored size: 1.46 KB

Contents

require 'new_relic/agent/instrumentation/controller_instrumentation'

DependencyDetection.defer do
  @name = :delayed_job
  
  depends_on do
    !NewRelic::Control.instance['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.debug '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

43 entries across 43 versions & 4 rubygems

Version Path
newrelic_rpm-3.4.1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.4.1.beta1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
ghazel-newrelic_rpm-3.4.0.2 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.4.0.1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.4.0 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.4.0.beta2 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.3.5 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.3.5.beta1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
newrelic_rpm-3.4.0.beta1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.8 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.7 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.6 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.5 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.4 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.3 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.1.fork2 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.3.4.1.fork lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.2.0.6 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
wd_newrelic_rpm-3.3.4.1 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb
dolores_rpm-3.2.0.5 lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb