class Instana::Backend::Agent
Wrapper class around the various transport backends @since 1.197.0
Attributes
delegate[R]
Public Class Methods
new(fargate_metadata_uri: ENV['ECS_CONTAINER_METADATA_URI'], logger: ::Instana.logger)
click to toggle source
# File lib/instana/backend/agent.rb, line 11 def initialize(fargate_metadata_uri: ENV['ECS_CONTAINER_METADATA_URI'], logger: ::Instana.logger) @delegate = nil @logger = logger @fargate_metadata_uri = fargate_metadata_uri end
Public Instance Methods
method_missing(mth, *args, &block)
click to toggle source
Calls superclass method
# File lib/instana/backend/agent.rb, line 35 def method_missing(mth, *args, &block) if @delegate.respond_to?(mth) @delegate.public_send(mth, *args, &block) else super(mth, *args, &block) end end
respond_to_missing?(mth, include_all = false)
click to toggle source
# File lib/instana/backend/agent.rb, line 43 def respond_to_missing?(mth, include_all = false) @delegate.respond_to?(mth, include_all) end
setup()
click to toggle source
# File lib/instana/backend/agent.rb, line 17 def setup @delegate = if ENV.key?('_HANDLER') ServerlessAgent.new([Snapshot::LambdaFunction.new]) elsif ENV.key?('K_REVISION') && ENV.key?('INSTANA_ENDPOINT_URL') ServerlessAgent.new([ Snapshot::GoogleCloudRunProcess.new, Snapshot::GoogleCloudRunInstance.new, Snapshot::RubyProcess.new ]) elsif @fargate_metadata_uri && ENV.key?('INSTANA_ENDPOINT_URL') ServerlessAgent.new(fargate_snapshots) else HostAgent.new end @delegate.setup end
Private Instance Methods
fargate_snapshots()
click to toggle source
# File lib/instana/backend/agent.rb, line 49 def fargate_snapshots metadata_uri = URI(@fargate_metadata_uri) client = Backend::RequestClient.new(metadata_uri.host, metadata_uri.port, use_ssl: metadata_uri.scheme == "https") response = client.send_request('GET', "#{metadata_uri.path}/task") if response.ok? docker = response .json['Containers'] .map { |c| [Snapshot::DockerContainer.new(c), Snapshot::FargateContainer.new(c)] } .flatten docker + [Snapshot::FargateProcess.new, Snapshot::RubyProcess.new, Snapshot::FargateTask.new] else @logger.warn("Received #{response.code} when requesting containers.") [] end end