Module: TingYun::Agent::Instrumentation::RakeInstrumentation
- Defined in:
- lib/ting_yun/instrumentation/rake.rb
Class Method Summary collapse
- .before_invoke_transaction(task) ⇒ Object
- .ensure_at_exit ⇒ Object
- .instrument_execute(task) ⇒ Object
- .instrument_execute_on_prereqs(task) ⇒ Object
- .instrument_invoke_prerequisites_concurrently(task) ⇒ Object
- .should_trace?(name) ⇒ Boolean
- .supported_version? ⇒ Boolean
Class Method Details
.before_invoke_transaction(task) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 49 def self.before_invoke_transaction(task) ensure_at_exit if task.application..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 ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 67 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) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 85 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) ⇒ Object
79 80 81 82 83 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 79 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) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 100 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) ⇒ Boolean
61 62 63 64 65 |
# File 'lib/ting_yun/instrumentation/rake.rb', line 61 def self.should_trace? name TingYun::Agent.config[:'rake.tasks'].any? do |task| task == name end end |
.supported_version? ⇒ Boolean
45 46 47 |
# 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 |