Module: Ecoportal::API::Common::ElasticApmIntegration

Included in:
Client
Defined in:
lib/ecoportal/api/common/elastic_apm_integration.rb

Defined Under Namespace

Classes: UnexpectedServerError

Constant Summary collapse

APM_SERVICE_NAME =
'ecoportal-api-gem'

Instance Method Summary collapse

Instance Method Details

#log_unexpected_server_error(response) ⇒ Object

Log only errors that are only server's responsibility



16
17
18
19
20
21
22
23
# File 'lib/ecoportal/api/common/elastic_apm_integration.rb', line 16

def log_unexpected_server_error(response)
  raise "Expecting Ecoportal::API::Common::Response. Given: #{response.class}" unless response.is_a?(Common::Response)
  return nil unless elastic_apm_service
  return nil unless unexpected_server_error?(response.status)
  if ElasticAPM.running?
    ElasticAPM.report(UnexpectedServerError.new(response.status, response.body))
  end
end