lib/elastic_apm/spies/faraday.rb in elastic-apm-4.7.0 vs lib/elastic_apm/spies/faraday.rb in elastic-apm-4.7.1

- old
+ new

@@ -107,10 +107,17 @@ result = super(method, url, body, headers) do |req| trace_context.apply_headers { |k, v| req[k] = v } yield req if block end rescue Faraday::ClientError, Faraday::ServerError => e # Faraday::Response::RaiseError - status = e.response_status + status = + if e.respond_to?(:response_status) + e.response_status + elsif e.response && e.response.respond_to?(:status) + e.response.status + elsif e.response && e.response.respond_to?(:fetch) + e.response[:status] + end http = span&.context&.http if http && status http.status_code = status.to_s span.outcome = Span::Outcome.from_http_status(status) end