lib/contrast/agent/thread_watcher.rb in contrast-agent-6.9.0 vs lib/contrast/agent/thread_watcher.rb in contrast-agent-6.10.0
- old
+ new
@@ -1,12 +1,11 @@
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true
require 'contrast/components/logger'
require 'contrast/agent/reporting/report'
-require 'contrast/agent/reporting/reporter_heartbeat'
-require 'contrast/agent/reporting/server_settings_worker'
+require 'contrast/agent/reporting/reporting_workers/reporting_workers'
require 'contrast/agent/telemetry/base'
require 'contrast/agent/protect/input_analyzer/worth_watching_analyzer'
require 'contrast/config/diagnostics'
module Contrast
@@ -17,36 +16,37 @@
# @return [Contrast::Utils::HeapDumpUtil]
attr_reader :heapdump_util
# @return [Contrast::Agent::Reporter]
attr_reader :reporter
- # @return [Contrast::Agent::ReporterHeartbeat]
+ # @return [Contrast::Agent::ReportingWorkers::ReporterHeartbeat]
attr_reader :reporter_heartbeat
# @return [Contrast::Agent::Protect::WorthWatchingInputAnalyzer]
attr_reader :worth_watching_analyzer
- # @return [Contrast::Agent::ServerSettingsWorker]
+ # @return [Contrast::Agent::ReportingWorkers::ServerSettingsWorker]
attr_reader :reporter_settings_worker
+ # @return [Contrast::Agent::ReportingWorkers::ApplicationServerWorker]
+ attr_reader :reporter_app_settings_worker
def initialize
@pids = {}
@heapdump_util = Contrast::Utils::HeapDumpUtil.new
@reporter = Contrast::Agent::Reporter.new
- @reporter_heartbeat = Contrast::Agent::ReporterHeartbeat.new
- @reporter_settings_worker = Contrast::Agent::ServerSettingsWorker.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
# @return [Hash, nil] map of process to thread startup status
def startup!
return unless ::Contrast::AGENT.enabled?
logger.debug('ThreadWatcher started threads')
- reporter_status = init_thread(reporter)
- reporter_heartbeat_status = init_thread(reporter_heartbeat)
- reporter_settings_worker_status = init_thread(reporter_settings_worker)
- @pids[Process.pid] = reporter_status && reporter_heartbeat_status && reporter_settings_worker_status
+
+ @pids[Process.pid] = reporter_threads
if Contrast::Agent::Telemetry::Base.enabled?
telemetry_status = init_thread(telemetry_queue)
@pids[Process.pid] = @pids[Process.pid] && telemetry_status
end
unless protect_disabled?
@@ -54,10 +54,15 @@
@pids[Process.pid] = @pids[Process.pid] && worth_watching_analyzer_status
end
@pids
end
+ def reporter_threads
+ init_thread(reporter) && init_thread(reporter_heartbeat) &&
+ init_thread(reporter_settings_worker) && init_thread(reporter_app_settings_worker)
+ end
+
def ensure_running?
return if @pids[Process.pid] == true
logger.debug('ThreadWatcher - threads not running')
startup!
@@ -82,9 +87,10 @@
telemetry_queue&.stop!
reporter&.stop!
reporter_heartbeat&.stop!
worth_watching_analyzer&.stop!
reporter_settings_worker&.stop!
+ reporter_app_settings_worker&.stop!
end
# @return [Contrast::Agent::Telemetry::Base]
def telemetry_queue
@telemetry