Class: OneApm::Agent::Harvester
- Inherits:
-
Object
- Object
- OneApm::Agent::Harvester
- Defined in:
- lib/one_apm/agent/harvester.rb
Instance Attribute Summary collapse
-
#starting_pid ⇒ Object
Returns the value of attribute starting_pid.
Instance Method Summary collapse
- #harvest_thread_enabled? ⇒ Boolean
-
#initialize(events, after_forker = OneApm::Manager) ⇒ Harvester
constructor
A new instance of Harvester.
- #mark_started(pid = Process.pid) ⇒ Object
- #needs_restart?(pid = Process.pid) ⇒ Boolean
- #on_transaction(*_) ⇒ Object
- #restart_harvest_thread ⇒ Object
- #restart_in_children_enabled? ⇒ Boolean
Constructor Details
#initialize(events, after_forker = OneApm::Manager) ⇒ Harvester
Returns a new instance of Harvester.
9 10 11 12 13 14 15 16 |
# File 'lib/one_apm/agent/harvester.rb', line 9 def initialize(events, after_forker = OneApm::Manager) @starting_pid = nil @after_forker = after_forker if events events.subscribe(:start_transaction, &method(:on_transaction)) end end |
Instance Attribute Details
#starting_pid ⇒ Object
Returns the value of attribute starting_pid.
7 8 9 |
# File 'lib/one_apm/agent/harvester.rb', line 7 def starting_pid @starting_pid end |
Instance Method Details
#harvest_thread_enabled? ⇒ Boolean
36 37 38 |
# File 'lib/one_apm/agent/harvester.rb', line 36 def harvest_thread_enabled? !OneApm::Manager.config[:disable_harvest_thread] end |
#mark_started(pid = Process.pid) ⇒ Object
24 25 26 |
# File 'lib/one_apm/agent/harvester.rb', line 24 def mark_started(pid = Process.pid) @starting_pid = pid end |
#needs_restart?(pid = Process.pid) ⇒ Boolean
28 29 30 |
# File 'lib/one_apm/agent/harvester.rb', line 28 def needs_restart?(pid = Process.pid) @starting_pid != pid end |
#on_transaction(*_) ⇒ Object
18 19 20 21 22 |
# File 'lib/one_apm/agent/harvester.rb', line 18 def on_transaction(*_) return unless restart_in_children_enabled? && needs_restart? && harvest_thread_enabled? restart_harvest_thread end |
#restart_harvest_thread ⇒ Object
40 41 42 |
# File 'lib/one_apm/agent/harvester.rb', line 40 def restart_harvest_thread @after_forker.after_fork(:force_reconnect => true) end |