44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 44
def harvest!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
active_threads = 0
result = @lock.synchronize do
elapsed_transaction_time = @stats.inject(0.0) do |total, (thread_id, entry)|
total + transaction_time_in_thread(timestamp, thread_id, entry)
end
active_threads = @stats.size
elapsed_harvest_time = (timestamp - @harvest_cycle_started_at) * active_threads
@harvest_cycle_started_at = timestamp
@stats.keep_if do |thread_id, _|
in_transaction?(thread_id) && thread_is_alive?(thread_id)
end
if elapsed_harvest_time > 0.0
elapsed_transaction_time / elapsed_harvest_time
else
0.0
end
end
if Agent.config[:report_instance_busy]
NewRelic::Agent.record_metric(INSTANCE_BUSY_METRIC, result)
end
result
end
|