module NewRelic::Thor::Instrumentation

Constants

BLACKLISTED_COMMAND_NAMES

Public Class Methods

included(base) click to toggle source
# File lib/newrelic/thor.rb, line 24
def self.included(base)
  base.class_eval do
    include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

    no_commands do
      alias_method :invoke_command_original, :invoke_command
      def invoke_command(*args)
        command = args.first
        return unless perform_trace_for_command?(command)
        ::NewRelic::Thor.start
        trace_options = {
          :class_name => self.class.name,
          :name => command.name,
          :category => "OtherTransaction/Thor"
        }
        perform_action_with_newrelic_trace(trace_options) do
          invoke_command_original(*args)
        end
      end
    end

    private

    def perform_trace_for_command?(command)
      !BLACKLISTED_COMMAND_NAMES.include?(command.name)
    end
  end
end

Public Instance Methods

invoke_command(*args) click to toggle source
# File lib/newrelic/thor.rb, line 30
def invoke_command(*args)
  command = args.first
  return unless perform_trace_for_command?(command)
  ::NewRelic::Thor.start
  trace_options = {
    :class_name => self.class.name,
    :name => command.name,
    :category => "OtherTransaction/Thor"
  }
  perform_action_with_newrelic_trace(trace_options) do
    invoke_command_original(*args)
  end
end
perform_trace_for_command?(command) click to toggle source
# File lib/newrelic/thor.rb, line 47
def perform_trace_for_command?(command)
  !BLACKLISTED_COMMAND_NAMES.include?(command.name)
end