Module: NewRelic::Agent::TransactionTimeAggregator
- Defined in:
- lib/new_relic/agent/transaction_time_aggregator.rb
Defined Under Namespace
Classes: TransactionStats
Constant Summary
collapse
- INSTANCE_BUSY_METRIC =
'Instance/Busy'.freeze
Class Method Summary
collapse
Class Method Details
.current_execution_context ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 77
def current_execution_context
if NewRelic::Agent.config[:dispatcher] == :falcon
Fiber.current
else
Thread.current
end
end
|
.current_execution_context_id ⇒ Object
85
86
87
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 85
def current_execution_context_id
current_execution_context.object_id
end
|
.harvest!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME)) ⇒ Object
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
|
.reset!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME)) ⇒ Object
24
25
26
27
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 24
def reset!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
@harvest_cycle_started_at = timestamp
@stats.clear
end
|
.transaction_start(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME)) ⇒ Object
29
30
31
32
33
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 29
def transaction_start(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
@lock.synchronize do
set_transaction_start_time(timestamp)
end
end
|
.transaction_stop(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), starting_thread_id = current_thread) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/new_relic/agent/transaction_time_aggregator.rb', line 35
def transaction_stop(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), starting_thread_id = current_thread)
@lock.synchronize do
record_elapsed_transaction_time_until(timestamp, starting_thread_id)
set_transaction_start_time(nil, starting_thread_id)
end
end
|