Class: Instana::Snapshot::GoogleCloudRunInstance
- Inherits:
-
Object
- Object
- Instana::Snapshot::GoogleCloudRunInstance
- Defined in:
- lib/instana/snapshot/google_cloud_run_instance.rb
Overview
Constant Summary collapse
- ID =
'com.instana.plugin.gcp.run.revision.instance'.freeze
Instance Method Summary collapse
- #data ⇒ Object
- #entity_id ⇒ Object
- #host_name ⇒ Object
-
#initialize(metadata_uri: 'http://metadata.google.internal') ⇒ GoogleCloudRunInstance
constructor
A new instance of GoogleCloudRunInstance.
- #snapshot ⇒ Object
- #source ⇒ Object
Constructor Details
#initialize(metadata_uri: 'http://metadata.google.internal') ⇒ GoogleCloudRunInstance
Returns a new instance of GoogleCloudRunInstance.
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
#data ⇒ Object
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_id ⇒ Object
15 16 17 |
# File 'lib/instana/snapshot/google_cloud_run_instance.rb', line 15 def entity_id lookup('/computeMetadata/v1/instance/id') end |
#host_name ⇒ Object
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 |
#snapshot ⇒ Object
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 |
#source ⇒ Object
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 |