Class: Instana::Snapshot::DockerContainer

Inherits:
Object
  • Object
show all
Includes:
Deltable
Defined in:
lib/instana/snapshot/docker_container.rb

Overview

Describes a Docker container visible to the current process

Since:

  • 1.197.0

Constant Summary collapse

ID =

Since:

  • 1.197.0

'com.instana.plugin.docker'.freeze

Instance Method Summary collapse

Methods included from Deltable

#delta

Constructor Details

#initialize(container, metadata_uri: ENV['ECS_CONTAINER_METADATA_URI']) ⇒ DockerContainer

Returns a new instance of DockerContainer.

Since:

  • 1.197.0



12
13
14
15
16
# File 'lib/instana/snapshot/docker_container.rb', line 12

def initialize(container, metadata_uri: ENV['ECS_CONTAINER_METADATA_URI'])
  @container = container
  @metadata_uri = URI()
  @client = Backend::RequestClient.new(@metadata_uri.host, @metadata_uri.port, use_ssl: @metadata_uri.scheme == "https")
end

Instance Method Details

#dataObject

Since:

  • 1.197.0



22
23
24
25
26
27
# File 'lib/instana/snapshot/docker_container.rb', line 22

def data
  metrics = lookup('/task/stats').fetch(@container['DockerId'], {})

  container_metrics(metrics)
    .merge()
end

#entity_idObject

Since:

  • 1.197.0



18
19
20
# File 'lib/instana/snapshot/docker_container.rb', line 18

def entity_id
  "#{@container['Labels']['com.amazonaws.ecs.task-arn']}::#{@container['Name']}"
end

#snapshotObject

Since:

  • 1.197.0



29
30
31
32
33
34
35
# File 'lib/instana/snapshot/docker_container.rb', line 29

def snapshot
  {
    name: ID,
    entityId: entity_id,
    data: data
  }
end