class Instana::Backend::HostAgent
@since 1.197.0
Attributes
client[R]
future[R]
Public Class Methods
new(discovery: Concurrent::Atom.new(nil), logger: ::Instana.logger)
click to toggle source
# File lib/instana/backend/host_agent.rb, line 10 def initialize(discovery: Concurrent::Atom.new(nil), logger: ::Instana.logger) @discovery = discovery @logger = logger @future = nil @client = nil end
Public Instance Methods
announce()
click to toggle source
# File lib/instana/backend/host_agent.rb, line 29 def announce @client = until_not_nil { HostAgentLookup.new.call } @discovery.delete_observers @discovery .with_observer(HostAgentActivationObserver.new(@client, @discovery)) .with_observer(HostAgentReportingObserver.new(@client, @discovery)) @discovery.swap { nil } @client end
Also aliased as: after_fork
extra_headers()
click to toggle source
@return [Array] extra headers to include in the trace
# File lib/instana/backend/host_agent.rb, line 56 def extra_headers discovery_value['extraHeaders'] end
ready?()
click to toggle source
@return [Boolean] true if the agent able to send spans to the backend
# File lib/instana/backend/host_agent.rb, line 43 def ready? ENV.key?('INSTANA_TEST') || !@discovery.value.nil? end
secret_values()
click to toggle source
@return [Hash] values which are removed from urls sent to the backend
# File lib/instana/backend/host_agent.rb, line 61 def secret_values discovery_value['secrets'] end
setup()
click to toggle source
# File lib/instana/backend/host_agent.rb, line 17 def setup; end
source()
click to toggle source
@return [Hash, NilClass] the backend friendly description of the current in process collector
# File lib/instana/backend/host_agent.rb, line 48 def source { e: discovery_value['pid'], h: discovery_value['agentUuid'] }.reject { |_, v| v.nil? } end
spawn_background_thread()
click to toggle source
# File lib/instana/backend/host_agent.rb, line 19 def spawn_background_thread return if ENV.key?('INSTANA_TEST') @future = Concurrent::Promises.future do announce end end
Also aliased as: start
Private Instance Methods
discovery_value()
click to toggle source
# File lib/instana/backend/host_agent.rb, line 77 def discovery_value v = @discovery.value v || {} end
until_not_nil() { || ... }
click to toggle source
# File lib/instana/backend/host_agent.rb, line 67 def until_not_nil loop do result = yield return result unless result.nil? @logger.debug("Waiting on a connection to the agent.") sleep(1) end end