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

Includes:
Ecoportal::API::Common::Client::Error::Checks
Included in:
WithRetry
Defined in:
lib/ecoportal/api/common/client/elastic_apm_integration.rb

Constant Summary collapse

APM_SERVICE_NAME =
'ecoportal-api-gem'.freeze

Instance Method Summary collapse

Instance Method Details

#log_unexpected_server_error(response) ⇒ Object

Log only errors that are only server's responsibility



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ecoportal/api/common/client/elastic_apm_integration.rb', line 12

def log_unexpected_server_error(response)
  msg = "Expecting Ecoportal::API::Common::Response. Given: #{response.class}"
  raise msg unless response.is_a?(Common::Response)

  return unless elastic_apm_service
  return unless unexpected_server_error_code?(response.status)
  return unless ElasticAPM.running?

  ElasticAPM.report(
    Ecoportal::API::Common::Client::Error::UnexpectedServerError.new(
      response.body,
      code: response.status
    )
  )
end