Module: NewRelic::Agent::Instrumentation::Rake::Tracer

Included in:
Prepend
Defined in:
lib/new_relic/agent/instrumentation/rake/instrumentation.rb

Constant Summary collapse

INSTRUMENTATION_NAME =
'Rake'

Instance Method Summary collapse

Instance Method Details

#invoke_with_newrelic_tracing(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/agent/instrumentation/rake/instrumentation.rb', line 12

def invoke_with_newrelic_tracing(*args)
  unless NewRelic::Agent::Instrumentation::Rake.should_trace?(name)
    return yield
  end

  NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

  begin
    timeout = NewRelic::Agent.config[:'rake.connect_timeout']
    NewRelic::Agent.instance.wait_on_connect(timeout)
  rescue => e
    NewRelic::Agent.logger.error('Exception in wait_on_connect', e)
    return yield
  end

  NewRelic::Agent::Instrumentation::Rake.before_invoke_transaction(self)

  NewRelic::Agent::Tracer.in_transaction(name: "OtherTransaction/Rake/invoke/#{name}", category: :rake) do
    NewRelic::Agent::Instrumentation::Rake.record_attributes(args, self)
    yield
  end
end