Sha256: 4c3c171484db93c17789c9bc745e2d6caf8ae1f024248314b24cfc8ae586f656

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'new_relic/agent/method_tracer'

DependencyDetection.defer do
  @name = :rake

  depends_on do
    defined?(::Rake) and not ::NewRelic::Control.instance['disable_rake']
  end

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

  executes do
    ::Rake::Task.class_eval do
      include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

      alias_method :origin_execute, :execute
      def execute(args=nil)
        if ignore_metric_reporting?
          origin_execute(args)
        else
          execute_with_newrelic_trace(args)
        end
      end

      def execute_with_newrelic_trace(args)
        unless ::NewRelic::Rake.started?
          ::NewRelic::Agent.manual_start
          ::NewRelic::Rake.started = true
        end
        perform_action_with_newrelic_trace(:name => self.name, :category => "OtherTransaction/Rake") do
          origin_execute(args)
        end
      end

      def ignore_metric_reporting?
        self.name == 'jobs:work'
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newrelic-rake-1.4.1 lib/newrelic-rake/instrument.rb