Class: Contrast::Agent::ReportingWorkers::ReporterHeartbeat

Inherits:
WorkerThread show all
Defined in:
lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb

Overview

The ReporterHeartbeat will make sure that the process remains marked alive by TeamServer and that we periodically reach out to get the latest settings for this application. It also sends out those messages which do not need to be associated directly with a request, such as Server Activity and Library Observation.

Constant Summary collapse

REFRESH_INTERVAL_SEC =

TeamServer will mark an application offline after 5 minutes. Sending this every one should be more than enough to satisfy our goals.

60

Instance Method Summary collapse

Methods inherited from WorkerThread

#attempt_to_start?, #clean_properties, #initialize, #running?, #stop!

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

This class inherits a constructor from Contrast::Agent::WorkerThread

Instance Method Details

#start_thread!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb', line 21

def start_thread!
  return unless attempt_to_start?
  return if running?

  @_thread = Contrast::Agent::Thread.new do
    logger.info('[Heartbeat] Starting thread.')
    loop do
      break unless attempt_to_start?

      polling_events.each do |event|
        Contrast::Agent.reporter&.send_event(event)
      end
      clean_properties
      sleep(REFRESH_INTERVAL_SEC)
    end
  end
end