Class: Datadog::Core::Cloudwise::AppRegistrationWorker
- Includes:
- Workers::Polling
- Defined in:
- lib/datadog/core/cloudwise/app_registration_worker.rb
Overview
Worker that registers application every 3 minutes 应用注册失败不影响数据采集
Constant Summary collapse
- DEFAULT_INTERVAL =
3 minutes interval
180- CODE_SUCCESS =
成功的状态码
1000
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) ⇒ AppRegistrationWorker
constructor
A new instance of AppRegistrationWorker.
- #perform ⇒ Object
- #registered? ⇒ Boolean
-
#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) ⇒ AppRegistrationWorker
Returns a new instance of AppRegistrationWorker.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/datadog/core/cloudwise/app_registration_worker.rb', line 22 def initialize(client:, logger:, probe_state:, **) @client = client @logger = logger @probe_state = probe_state @registration_successful = false # 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.
20 21 22 |
# File 'lib/datadog/core/cloudwise/app_registration_worker.rb', line 20 def client @client end |
Instance Method Details
#perform ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/datadog/core/cloudwise/app_registration_worker.rb', line 37 def perform # Wait for Host ID to be generated unless client.account_id Cloudwise.log_debug { 'Cloudwise: Waiting for Host ID generation before application registration' } return true end Cloudwise.log_debug { 'Cloudwise: Registering application' } result = client.register_application process_registration_result(result) true rescue => e Cloudwise.log_error { "Cloudwise: Application registration worker error: #{e.class.name} #{e.}" } @probe_state.mark_app_unregistered! true # Continue running end |
#registered? ⇒ Boolean
57 58 59 |
# File 'lib/datadog/core/cloudwise/app_registration_worker.rb', line 57 def registered? @registration_successful end |
#start ⇒ Object
Public method to start the worker
62 63 64 65 66 67 |
# File 'lib/datadog/core/cloudwise/app_registration_worker.rb', line 62 def start return false if !enabled? || started? # Start the async worker thread perform end |