Sha256: b56902e94e8def171c15e0faa61684ea66b9dcec5f969b1a7835fe297abec90b
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# encoding: utf-8 module OneApm module Agent class Harvester attr_accessor :starting_pid # Inject target for after_fork call to avoid spawning thread in tests def initialize(events, after_forker = OneApm::Agent) # We intentionally don't set our pid as started at this point. # Startup routines must call mark_started when they consider us set! @starting_pid = nil @after_forker = after_forker if events events.subscribe(:start_transaction, &method(:on_transaction)) end end def on_transaction(*_) return unless restart_in_children_enabled? && needs_restart? && harvest_thread_enabled? restart_harvest_thread end def mark_started(pid = Process.pid) @starting_pid = pid end def needs_restart?(pid = Process.pid) @starting_pid != pid end def restart_in_children_enabled? OneApm::Agent.config[:restart_thread_in_children] end def harvest_thread_enabled? !OneApm::Agent.config[:disable_harvest_thread] end def restart_harvest_thread @after_forker.after_fork(:force_reconnect => true) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oneapm_rpm-1.1.2 | lib/one_apm/agent/harvester.rb |
oneapm_rpm-1.1.1 | lib/one_apm/agent/harvester.rb |
oneapm_rpm-1.1.0 | lib/one_apm/agent/harvester.rb |