diff --git a/CHANGELOG.md b/CHANGELOG.md index 139c2be07..1fd6e5f5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Bug Fixes + +- HTTP client spans now include status based on `http.request.method` ([#2650](https://github.com/getsentry/sentry-ruby/pull/2650)) + ## 5.25.0 ### Features diff --git a/sentry-ruby/lib/sentry/utils/http_tracing.rb b/sentry-ruby/lib/sentry/utils/http_tracing.rb index c8e100003..174b29da2 100644 --- a/sentry-ruby/lib/sentry/utils/http_tracing.rb +++ b/sentry-ruby/lib/sentry/utils/http_tracing.rb @@ -8,7 +8,7 @@ def set_span_info(sentry_span, request_info, response_status) sentry_span.set_data(Span::DataConventions::URL, request_info[:url]) sentry_span.set_data(Span::DataConventions::HTTP_METHOD, request_info[:method]) sentry_span.set_data(Span::DataConventions::HTTP_QUERY, request_info[:query]) if request_info[:query] - sentry_span.set_data(Span::DataConventions::HTTP_STATUS_CODE, response_status) + sentry_span.set_http_status(response_status) end def set_propagation_headers(req) diff --git a/sentry-ruby/spec/sentry/net/http_spec.rb b/sentry-ruby/spec/sentry/net/http_spec.rb index 91402fc79..6e021cddb 100644 --- a/sentry-ruby/spec/sentry/net/http_spec.rb +++ b/sentry-ruby/spec/sentry/net/http_spec.rb @@ -36,6 +36,7 @@ expect(request_span.data).to eq( { "url" => "http://[::1]/path", "http.request.method" => "GET", "http.response.status_code" => 200 } ) + expect(request_span.status).to eq("ok") end end @@ -68,6 +69,7 @@ "http.request.method" => "GET", "http.query" => "foo=bar" }) + expect(request_span.status).to eq("ok") end end @@ -99,6 +101,7 @@ "url" => "http://example.com/path", "http.request.method" => "GET" }) + expect(request_span.status).to eq("ok") end end @@ -342,6 +345,7 @@ def verify_spans(transaction) "url" => "http://example.com/path", "http.request.method" => "GET" }) + expect(request_span.status).to eq("ok") request_span = transaction.span_recorder.spans[2] expect(request_span.op).to eq("http.client") @@ -355,6 +359,7 @@ def verify_spans(transaction) "url" => "http://example.com/path", "http.request.method" => "GET" }) + expect(request_span.status).to eq("not_found") end it "doesn't mess different requests' data together" do