Class: Datadog::Core::Remote::Component
- Inherits:
-
Object
- Object
- Datadog::Core::Remote::Component
- Defined in:
- lib/datadog/core/remote/component.rb
Overview
Configures the HTTP transport to communicate with the agent to fetch and sync the remote configuration
Defined Under Namespace
Classes: Barrier
Constant Summary collapse
- BARRIER_TIMEOUT =
second
1.0
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #barrier(kind) ⇒ Object
-
#initialize(settings, agent_settings) ⇒ Component
constructor
A new instance of Component.
- #shutdown! ⇒ Object
Constructor Details
#initialize(settings, agent_settings) ⇒ Component
Returns a new instance of Component.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/datadog/core/remote/component.rb', line 19 def initialize(settings, agent_settings) = {} [:agent_settings] = agent_settings if agent_settings transport_v7 = Datadog::Core::Transport::HTTP.v7(**.dup) capabilities = Client::Capabilities.new(settings) @barrier = Barrier.new(BARRIER_TIMEOUT) @client = Client.new(transport_v7, capabilities) @worker = Worker.new(interval: settings.remote.poll_interval_seconds) do begin @client.sync rescue StandardError => e Datadog.logger.error do "remote worker error: #{e.class.name} #{e.} location: #{Array(e.backtrace).first}" end # client state is unknown, state might be corrupted @client = Client.new(transport_v7, capabilities) # TODO: bail out if too many errors? end @barrier.lift end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
17 18 19 |
# File 'lib/datadog/core/remote/component.rb', line 17 def client @client end |
Class Method Details
.build(settings, agent_settings) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/datadog/core/remote/component.rb', line 116 def build(settings, agent_settings) return unless settings.remote.enabled = {} [:agent_settings] = agent_settings if agent_settings transport_root = Datadog::Core::Transport::HTTP.root(**.dup) res = transport_root.send_info if res.ok? if res.endpoints.include?('/v0.7/config') Datadog.logger.debug { 'agent reachable and reports remote configuration endpoint' } else Datadog.logger.error do 'agent reachable but does not report remote configuration endpoint: ' \ 'disabling remote configuration for this process.' end return end else Datadog.logger.error do 'agent unreachable: disabling remote configuration for this process.' end return end new(settings, agent_settings) end |
Instance Method Details
#barrier(kind) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/datadog/core/remote/component.rb', line 48 def (kind) @worker.start case kind when :once @barrier.wait_once end end |
#shutdown! ⇒ Object
57 58 59 |
# File 'lib/datadog/core/remote/component.rb', line 57 def shutdown! @worker.stop end |