module TingYun::Agent::Instrumentation::RakeInstrumentation

Public Class Methods

before_invoke_transaction(task) click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 49
def self.before_invoke_transaction(task)
  ensure_at_exit

  if task.application.options.always_multitask
    instrument_invoke_prerequisites_concurrently(task)
  else
    instrument_execute_on_prereqs(task)
  end
rescue => e
  TingYun::Agent.logger.error("Error during Rake task invoke", e)
end
ensure_at_exit() click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 68
def self.ensure_at_exit
  return if @installed_at_exit

  at_exit do
    # The agent's default at_exit might not default to installing, but
    # if we are running an instrumented rake task, we always want it.
    TingYun::Agent.shutdown
  end

  @installed_at_exit = true
end
instrument_execute(task) click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 86
def self.instrument_execute(task)
  return if task.instance_variable_get(:@__tingyun_instrumented_execute)

  task.instance_variable_set(:@__tingyun_instrumented_execute, true)
  task.instance_eval do
    def execute(*args, &block)
      TingYun::Agent::MethodTracerHelpers.trace_execution_scoped("Rake/execute/#{self.name}") do
        super
      end
    end
  end

  instrument_execute_on_prereqs(task)
end
instrument_execute_on_prereqs(task) click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 80
def self.instrument_execute_on_prereqs(task)
  task.prerequisite_tasks.each do |child_task|
    instrument_execute(child_task)
  end
end
instrument_invoke_prerequisites_concurrently(task) click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 101
def self.instrument_invoke_prerequisites_concurrently(task)
  task.instance_eval do
    def invoke_prerequisites_concurrently(*_)
      TingYun::Agent::MethodTracerHelpers.trace_execution_scoped("Rake/execute/multitask") do
        super
      end
    end
  end
end
should_trace?(name) click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 61
def self.should_trace? name

  return ::TingYun::Agent.config[:'rake.tasks'].include?(name) if ::TingYun::Agent.config[:'rake.tasks'].any?
  return !TingYun::Agent.config[:'rake.black.tasks'].include?(name) if ::TingYun::Agent.config[:'rake.black.tasks'].any?
  return false
end
supported_instrument?() click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 111
def self.supported_instrument?
  ::TingYun::Agent.config[:'rake.tasks'].any? or ::TingYun::Agent.config[:'rake.black.tasks'].any?
end
supported_version?() click to toggle source
# File lib/ting_yun/instrumentation/rake.rb, line 45
def self.supported_version?
  ::TingYun::Support::VersionNumber.new(::Rake::VERSION) >= ::TingYun::Support::VersionNumber.new("10.0.0")
end

Public Instance Methods

execute(*args, &block) click to toggle source
Calls superclass method
# File lib/ting_yun/instrumentation/rake.rb, line 91
def execute(*args, &block)
  TingYun::Agent::MethodTracerHelpers.trace_execution_scoped("Rake/execute/#{self.name}") do
    super
  end
end
invoke_prerequisites_concurrently(*_) click to toggle source
Calls superclass method
# File lib/ting_yun/instrumentation/rake.rb, line 103
def invoke_prerequisites_concurrently(*_)
  TingYun::Agent::MethodTracerHelpers.trace_execution_scoped("Rake/execute/multitask") do
    super
  end
end