7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/new_relic/agent/instrumentation/concurrent_ruby/chain.rb', line 7
def self.instrument!
::Concurrent::ThreadPoolExecutor.class_eval do
include NewRelic::Agent::Instrumentation::ConcurrentRuby
alias_method(:post_without_new_relic, :post)
def post(*args, &task)
return post_without_new_relic(*args, &task) unless NewRelic::Agent::Tracer.tracing_enabled?
traced_task = add_task_tracing(&task)
post_without_new_relic(*args, &traced_task)
end
end
[::Concurrent::Promises.const_get(:'InternalStates')::Rejected,
::Concurrent::Promises.const_get(:'InternalStates')::PartiallyRejected].each do |klass|
klass.class_eval do
alias_method(:initialize_without_new_relic, :initialize)
def initialize(*args)
NewRelic::Agent.notice_error(args.last) if args.last.is_a?(Exception)
initialize_without_new_relic(*args)
end
end
end
end
|