Class: Instana::Snapshot::GoogleCloudRunInstance

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

Overview

Since:

  • 1.199

Constant Summary collapse

ID =

Since:

  • 1.199

'com.instana.plugin.gcp.run.revision.instance'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(metadata_uri: 'http://metadata.google.internal') ⇒ GoogleCloudRunInstance

Returns a new instance of GoogleCloudRunInstance.

Since:

  • 1.199



10
11
12
13
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 10

def initialize(metadata_uri: 'http://metadata.google.internal')
   = URI()
  @client = Backend::RequestClient.new(.host, .port, use_ssl: .scheme == "https")
end

Instance Method Details

#dataObject

Since:

  • 1.199



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 19

def data
  {
    runtime: 'ruby',
    region: gcp_region,
    service: ENV['K_SERVICE'],
    configuration: ENV['K_CONFIGURATION'],
    revision: ENV['K_REVISION'],
    instanceId: entity_id,
    port: ENV['PORT'],
    numericProjectId: lookup('/computeMetadata/v1/project/numeric-project-id'),
    projectId: lookup('/computeMetadata/v1/project/project-id')
  }.reject { |_, v| v.nil? }
end

#entity_idObject

Since:

  • 1.199



15
16
17
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 15

def entity_id
  lookup('/computeMetadata/v1/instance/id')
end

#host_nameObject

Since:

  • 1.199



49
50
51
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 49

def host_name
  "gcp:cloud-run:revision:#{ENV['K_REVISION']}"
end

#snapshotObject

Since:

  • 1.199



33
34
35
36
37
38
39
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 33

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

#sourceObject

Since:

  • 1.199



41
42
43
44
45
46
47
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 41

def source
  {
    hl: true,
    cp: 'gcp',
    e: entity_id
  }
end