Class: Datadog::Core::Cloudwise::DOCCHeartbeatWorker
- Includes:
- Workers::Polling
- Defined in:
- lib/datadog/core/cloudwise/docc_heartbeat_worker.rb
Overview
Worker that sends heartbeat to DOCC every 30 seconds with retry mechanism DOCC 心跳纳管 Worker 心跳失败 3 次后标记为无心跳,数据不采集
Constant Summary collapse
- DEFAULT_INTERVAL =
30 seconds interval
30- MAX_RETRIES =
Max retries: 3 times
3- DOCC_CODE_SUCCESS =
成功的状态码
100000
Constants included from Workers::Polling
Workers::Polling::DEFAULT_SHUTDOWN_TIMEOUT
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Worker
Instance Method Summary collapse
-
#initialize(client:, logger:, probe_state:, **options) ⇒ DOCCHeartbeatWorker
constructor
A new instance of DOCCHeartbeatWorker.
- #perform ⇒ Object
-
#start ⇒ Object
Public method to start the worker.
Methods included from Workers::Polling
#enabled=, #enabled?, included, #stop
Constructor Details
#initialize(client:, logger:, probe_state:, **options) ⇒ DOCCHeartbeatWorker
Returns a new instance of DOCCHeartbeatWorker.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/core/cloudwise/docc_heartbeat_worker.rb', line 25 def initialize(client:, logger:, probe_state:, **) @client = client @logger = logger @probe_state = probe_state @failure_count = 0 # Workers::Async::Thread settings self.fork_policy = .fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP) # Workers::IntervalLoop settings self.loop_base_interval = .fetch(:interval, DEFAULT_INTERVAL) self.enabled = .fetch(:enabled, true) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/datadog/core/cloudwise/docc_heartbeat_worker.rb', line 23 def client @client end |
Instance Method Details
#perform ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/datadog/core/cloudwise/docc_heartbeat_worker.rb', line 40 def perform Cloudwise.log_debug { 'Cloudwise DOCC: Sending heartbeat' } result = client.docc_heartbeat_ext process_heartbeat_result(result) true rescue => e Cloudwise.log_error { "Cloudwise DOCC: Heartbeat worker error: #{e.class.name} #{e.message}" } handle_heartbeat_failure true # Continue running end |
#start ⇒ Object
Public method to start the worker
55 56 57 58 59 60 |
# File 'lib/datadog/core/cloudwise/docc_heartbeat_worker.rb', line 55 def start return false if !enabled? || started? # Start the async worker thread perform end |