Class: ElasticAPM::Config::ServerInfo Private

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_apm/config/server_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

VERSION_8_0 =

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.

'8.0'
VERSION_0 =

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.

'0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ServerInfo

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 ServerInfo.



29
30
31
32
# File 'lib/elastic_apm/config/server_info.rb', line 29

def initialize(config)
  @config = config
  @http = Transport::Connection::Http.new(config)
end

Instance Attribute Details

#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.



24
25
26
# File 'lib/elastic_apm/config/server_info.rb', line 24

def config
  @config
end

#httpObject (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.



24
25
26
# File 'lib/elastic_apm/config/server_info.rb', line 24

def http
  @http
end

#payloadObject (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.



24
25
26
# File 'lib/elastic_apm/config/server_info.rb', line 24

def payload
  @payload
end

Instance Method Details

#executeObject

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.



34
35
36
37
38
39
# File 'lib/elastic_apm/config/server_info.rb', line 34

def execute
  resp = http.get(config.server_url)
  @payload = JSON.parse(resp.body)
rescue
  @payload = { "version" => VERSION_0 }
end

#versionObject

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.



41
42
43
44
45
46
# File 'lib/elastic_apm/config/server_info.rb', line 41

def version
  @version ||= begin
    execute
    payload["version"] ? payload["version"].to_s : VERSION_0
  end
end