Class: Nonnative::Observability

Inherits:
HTTPClient show all
Defined in:
lib/nonnative/observability.rb

Overview

HTTP client for common observability endpoints exposed by the system under test.

This client is returned by observability and builds endpoint paths from Configuration#name.

Endpoints:

  • ‘/<name>/healthz`

  • ‘/<name>/livez`

  • ‘/<name>/readyz`

  • ‘/<name>/metrics`

Requests are performed using HTTPClient, so callers may pass RestClient options such as headers, open_timeout, and read_timeout.

Examples:

Nonnative.configure do |config|
  config.name = 'my-service'
  config.url = 'http://127.0.0.1:8080'
end

response = Nonnative.observability.health(read_timeout: 2, open_timeout: 2)
response.code # => 200

See Also:

Instance Method Summary collapse

Methods inherited from HTTPClient

#initialize

Constructor Details

This class inherits a constructor from Nonnative::HTTPClient

Instance Method Details

#health(opts = {}) ⇒ RestClient::Response, String

Calls ‘/<name>/healthz`.

Parameters:

  • opts (Hash) (defaults to: {})

    RestClient options (e.g. headers, read_timeout, open_timeout)

Returns:

  • (RestClient::Response, String)

    response for non-2xx errors, otherwise the RestClient result



34
35
36
# File 'lib/nonnative/observability.rb', line 34

def health(opts = {})
  get("#{name}/healthz", opts)
end

#liveness(opts = {}) ⇒ RestClient::Response, String

Calls ‘/<name>/livez`.

Parameters:

  • opts (Hash) (defaults to: {})

    RestClient options (e.g. headers, read_timeout, open_timeout)

Returns:

  • (RestClient::Response, String)

    response for non-2xx errors, otherwise the RestClient result



42
43
44
# File 'lib/nonnative/observability.rb', line 42

def liveness(opts = {})
  get("#{name}/livez", opts)
end

#metrics(opts = {}) ⇒ RestClient::Response, String

Calls ‘/<name>/metrics`.

Parameters:

  • opts (Hash) (defaults to: {})

    RestClient options (e.g. headers, read_timeout, open_timeout)

Returns:

  • (RestClient::Response, String)

    response for non-2xx errors, otherwise the RestClient result



58
59
60
# File 'lib/nonnative/observability.rb', line 58

def metrics(opts = {})
  get("#{name}/metrics", opts)
end

#readiness(opts = {}) ⇒ RestClient::Response, String

Calls ‘/<name>/readyz`.

Parameters:

  • opts (Hash) (defaults to: {})

    RestClient options (e.g. headers, read_timeout, open_timeout)

Returns:

  • (RestClient::Response, String)

    response for non-2xx errors, otherwise the RestClient result



50
51
52
# File 'lib/nonnative/observability.rb', line 50

def readiness(opts = {})
  get("#{name}/readyz", opts)
end