Module: NewRelic::Agent::Instrumentation::DispatcherInstrumentation::BusyCalculator
- Extended by:
- BusyCalculator
- Included in:
- BusyCalculator
- Defined in:
- lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb
Overview
This won’t work with Rails 2.2 multi-threading
Instance Method Summary collapse
- #dispatcher_finish(time) ⇒ Object
- #dispatcher_start(time) ⇒ Object
- #harvest_busy ⇒ Object
- #is_busy? ⇒ Boolean
Instance Method Details
#dispatcher_finish(time) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb', line 64 def dispatcher_finish(time) Thread.critical = true @accumulator += (time - @dispatcher_start) @dispatcher_start = nil Thread.critical = false end |
#dispatcher_start(time) ⇒ Object
58 59 60 61 62 |
# File 'lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb', line 58 def dispatcher_start(time) Thread.critical = true @dispatcher_start = time Thread.critical = false end |
#harvest_busy ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb', line 76 def harvest_busy Thread.critical = true busy = @accumulator @accumulator = 0 t0 = Time.now.to_f if @dispatcher_start busy += (t0 - @dispatcher_start) @dispatcher_start = t0 end Thread.critical = false busy = 0.0 if busy < 0.0 # don't go below 0% time_window = (t0 - @harvest_start) time_window = 1.0 if time_window == 0.0 # protect against divide by zero busy = busy / time_window busy = 1.0 if busy > 1.0 # cap at 100% @instance_busy.record_data_point busy @harvest_start = t0 end |
#is_busy? ⇒ Boolean
72 73 74 |
# File 'lib/new_relic/agent/instrumentation/dispatcher_instrumentation.rb', line 72 def is_busy? @dispatcher_start end |