Class: Instana::Snapshot::FargateProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/instana/snapshot/fargate_process.rb

Overview

Describes the current process in terms of its existence inside of a Fargate container

Since:

  • 1.197.0

Constant Summary collapse

ID =

Since:

  • 1.197.0

'com.instana.plugin.process'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(metadata_uri: ENV['ECS_CONTAINER_METADATA_URI']) ⇒ FargateProcess

Returns a new instance of FargateProcess.

Since:

  • 1.197.0



11
12
13
14
15
# File 'lib/instana/snapshot/fargate_process.rb', line 11

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

Instance Method Details

#dataObject

Since:

  • 1.197.0



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/instana/snapshot/fargate_process.rb', line 21

def data
  proc_table = Sys::ProcTable.ps(pid: Process.pid)
  process = Backend::ProcessInfo.new(proc_table)

  {
    pid: process.pid.to_i,
    env: ENV.to_h,
    exec: process.name,
    args: process.arguments,
    user: process.uid,
    group: process.gid,
    start: @start_time.to_i * 1000,
    containerType: 'docker',
    container: container_id,
    "com.instana.plugin.host.name": task_id
  }
end

#entity_idObject

Since:

  • 1.197.0



17
18
19
# File 'lib/instana/snapshot/fargate_process.rb', line 17

def entity_id
  Process.pid.to_s
end

#snapshotObject

Since:

  • 1.197.0



39
40
41
42
43
44
45
# File 'lib/instana/snapshot/fargate_process.rb', line 39

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