Class: Contrast::Agent::ThreadWatcher
- Includes:
- Components::Logger::InstanceMethods
- Defined in:
- lib/contrast/agent/thread/thread_watcher.rb
Overview
This class used to ensure that our worker threads are running in multi-process environments
Instance Attribute Summary collapse
- #heapdump_util ⇒ Contrast::Utils::HeapDumpUtil readonly
- #reporter ⇒ Contrast::Agent::Reporter readonly
- #reporter_app_settings_worker ⇒ Contrast::Agent::ReportingWorkers::ApplicationServerWorker readonly
- #reporter_heartbeat ⇒ Contrast::Agent::ReportingWorkers::ReporterHeartbeat readonly
- #reporter_settings_worker ⇒ Contrast::Agent::ReportingWorkers::ServerSettingsWorker readonly
- #worth_watching_analyzer ⇒ Contrast::Agent::Protect::WorthWatchingInputAnalyzer readonly
Instance Method Summary collapse
- #ensure_running? ⇒ Boolean
-
#initialize ⇒ ThreadWatcher
constructor
A new instance of ThreadWatcher.
- #shutdown! ⇒ Object
-
#startup! ⇒ Array<Contrast::Agent::WorkerThread>
Map of process to thread startup status.
- #telemetry_queue ⇒ Contrast::Agent::Telemetry::Base
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize ⇒ ThreadWatcher
Returns a new instance of ThreadWatcher.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 31 def initialize if Contrast::AGENT.disabled? || Contrast::Utils::JobServersRunning.job_servers_running? logger.info('Agent Disabled, shutting down all threads...') return end @heapdump_util = Contrast::Utils::HeapDumpUtil.new @reporter = Contrast::Agent::Reporter.new @reporter_heartbeat = Contrast::Agent::ReportingWorkers::ReporterHeartbeat.new @reporter_settings_worker = Contrast::Agent::ReportingWorkers::ServerSettingsWorker.new @reporter_app_settings_worker = Contrast::Agent::ReportingWorkers::ApplicationServerWorker.new @telemetry = Contrast::Agent::Telemetry::Base.new if Contrast::Agent::Telemetry::Base.enabled? @worth_watching_analyzer = Contrast::Agent::Protect::WorthWatchingInputAnalyzer.new unless protect_disabled? end |
Instance Attribute Details
#heapdump_util ⇒ Contrast::Utils::HeapDumpUtil (readonly)
19 20 21 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 19 def heapdump_util @heapdump_util end |
#reporter ⇒ Contrast::Agent::Reporter (readonly)
21 22 23 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 21 def reporter @reporter end |
#reporter_app_settings_worker ⇒ Contrast::Agent::ReportingWorkers::ApplicationServerWorker (readonly)
29 30 31 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 29 def reporter_app_settings_worker @reporter_app_settings_worker end |
#reporter_heartbeat ⇒ Contrast::Agent::ReportingWorkers::ReporterHeartbeat (readonly)
23 24 25 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 23 def reporter_heartbeat @reporter_heartbeat end |
#reporter_settings_worker ⇒ Contrast::Agent::ReportingWorkers::ServerSettingsWorker (readonly)
27 28 29 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 27 def reporter_settings_worker @reporter_settings_worker end |
#worth_watching_analyzer ⇒ Contrast::Agent::Protect::WorthWatchingInputAnalyzer (readonly)
25 26 27 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 25 def worth_watching_analyzer @worth_watching_analyzer end |
Instance Method Details
#ensure_running? ⇒ Boolean
59 60 61 62 63 64 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 59 def ensure_running? return if desired_threads.all?(&:running?) logger.debug('ThreadWatcher - threads not running') startup! end |
#shutdown! ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 66 def shutdown! heapdump_util&.stop! telemetry_queue&.stop! reporter&.stop! reporter_heartbeat&.stop! worth_watching_analyzer&.stop! reporter_settings_worker&.stop! reporter_app_settings_worker&.stop! end |
#startup! ⇒ Array<Contrast::Agent::WorkerThread>
Returns map of process to thread startup status.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 47 def startup! check_before_start return unless ::Contrast::AGENT.enabled? logger.debug('ThreadWatcher started threads') desired_threads.each do |thread| init_thread(thread) end end |
#telemetry_queue ⇒ Contrast::Agent::Telemetry::Base
77 78 79 |
# File 'lib/contrast/agent/thread/thread_watcher.rb', line 77 def telemetry_queue @telemetry end |