Class: Instana::Backend::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/backend/agent.rb

Overview

Wrapper class around the various transport backends

Since:

  • 1.197.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fargate_metadata_uri: ENV['ECS_CONTAINER_METADATA_URI'], logger: ::Instana.logger) ⇒ Agent

Returns a new instance of Agent.

Since:

  • 1.197.0



11
12
13
14
15
# 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 = 
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mth, *args, &block) ⇒ Object

Since:

  • 1.197.0



35
36
37
38
39
40
41
# 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

Instance Attribute Details

#delegateObject (readonly)

Since:

  • 1.197.0



9
10
11
# File 'lib/instana/backend/agent.rb', line 9

def delegate
  @delegate
end

Instance Method Details

#respond_to_missing?(mth, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 1.197.0



43
44
45
# File 'lib/instana/backend/agent.rb', line 43

def respond_to_missing?(mth, include_all = false)
  @delegate.respond_to?(mth, include_all)
end

#setupObject

Since:

  • 1.197.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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