Class: ElasticAPM::Metadata::CloudInfo Private

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/elastic_apm/metadata/cloud_info.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

AWS_URI =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"http://169.254.169.254/latest/dynamic/instance-identity/document"
GCP_URI =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"http://metadata.google.internal/computeMetadata/v1/?recursive=true"
AZURE_URI =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15"

Constants included from Logging

Logging::LEVELS, Logging::PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(config) ⇒ CloudInfo

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CloudInfo.



32
33
34
35
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 32

def initialize(config)
  @config = config
  @client = HTTP.timeout(connect: 0.1, read: 0.1)
end

Instance Attribute Details

#account_idObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def 
  @account_id
end

#account_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def 
  @account_name
end

#availability_zoneObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def availability_zone
  @availability_zone
end

#configObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 37

def config
  @config
end

#instance_idObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def instance_id
  @instance_id
end

#instance_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def instance_name
  @instance_name
end

#machine_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def machine_type
  @machine_type
end

#project_idObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def project_id
  @project_id
end

#project_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def project_name
  @project_name
end

#providerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def provider
  @provider
end

#regionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 39

def region
  @region
end

Instance Method Details

#fetch!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/CyclomaticComplexity



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/elastic_apm/metadata/cloud_info.rb', line 53

def fetch!
  case config.cloud_provider
  when "aws"
    fetch_aws
  when "gcp"
    fetch_gcp
  when "azure"
    fetch_azure || read_azure_app_services
  when "auto"
    fetch_aws || fetch_gcp || fetch_azure || read_azure_app_services
  when "none"
    nil
  else
    error("Unknown setting for cloud_provider '#{config.cloud_provider}'")
  end

  self
end