From ce284563121376587dce3955c2529cb6c04fcacd Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 12 Jun 2025 14:33:51 +0100 Subject: [PATCH 1/2] Use set_http_status in Utils::HttpTracing instead of set_data so that spans get their status set correctly. --- sentry-ruby/lib/sentry/utils/http_tracing.rb | 2 +- sentry-ruby/spec/sentry/net/http_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 From 4cbcea74612740706c093b0a8357783e759b7554 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Thu, 12 Jun 2025 14:50:20 +0100 Subject: [PATCH 2/2] Add changelog. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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