From 300fc945ea3e61a3c2390ee920847182b077dffd Mon Sep 17 00:00:00 2001 From: Emily Stolfo Date: Mon, 25 Sep 2023 16:35:24 +0200 Subject: [PATCH] Use response method on Faraday error for older versions of the library --- lib/elastic_apm/spies/faraday.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/elastic_apm/spies/faraday.rb b/lib/elastic_apm/spies/faraday.rb index 3d81d2066..331b2d3ec 100644 --- a/lib/elastic_apm/spies/faraday.rb +++ b/lib/elastic_apm/spies/faraday.rb @@ -109,7 +109,8 @@ def run_request(method, url, body, headers, &block) yield req if block end rescue Faraday::ClientError, Faraday::ServerError => e # Faraday::Response::RaiseError - status = e.response_status + status = e.response_status if e.respond_to?(:response_status) + status ||= e.response&.fetch(:status) http = span&.context&.http if http && status http.status_code = status.to_s