diff --git a/sentry-ruby/spec/sentry/net/http_spec.rb b/sentry-ruby/spec/sentry/net/http_spec.rb index b4930a5b9..08499c99a 100644 --- a/sentry-ruby/spec/sentry/net/http_spec.rb +++ b/sentry-ruby/spec/sentry/net/http_spec.rb @@ -91,24 +91,56 @@ def stub_normal_response(code: "200") end end - it "records the request's span" do - stub_normal_response + context "with config.send_default_pii = true" do + before do + Sentry.configuration.send_default_pii = true + end - transaction = Sentry.start_transaction - Sentry.get_current_scope.set_span(transaction) + it "records the request's span with query string" do + stub_normal_response - response = Net::HTTP.get_response(URI("http://example.com/path")) + transaction = Sentry.start_transaction + Sentry.get_current_scope.set_span(transaction) - expect(response.code).to eq("200") - expect(transaction.span_recorder.spans.count).to eq(2) + response = Net::HTTP.get_response(URI("http://example.com/path?foo=bar")) - request_span = transaction.span_recorder.spans.last - expect(request_span.op).to eq("net.http") - expect(request_span.start_timestamp).not_to be_nil - expect(request_span.timestamp).not_to be_nil - expect(request_span.start_timestamp).not_to eq(request_span.timestamp) - expect(request_span.description).to eq("GET http://example.com/path") - expect(request_span.data).to eq({ status: 200 }) + expect(response.code).to eq("200") + expect(transaction.span_recorder.spans.count).to eq(2) + + request_span = transaction.span_recorder.spans.last + expect(request_span.op).to eq("net.http") + expect(request_span.start_timestamp).not_to be_nil + expect(request_span.timestamp).not_to be_nil + expect(request_span.start_timestamp).not_to eq(request_span.timestamp) + expect(request_span.description).to eq("GET http://example.com/path?foo=bar") + expect(request_span.data).to eq({ status: 200 }) + end + end + + context "with config.send_default_pii = true" do + before do + Sentry.configuration.send_default_pii = false + end + + it "records the request's span with query string" do + stub_normal_response + + transaction = Sentry.start_transaction + Sentry.get_current_scope.set_span(transaction) + + response = Net::HTTP.get_response(URI("http://example.com/path?foo=bar")) + + expect(response.code).to eq("200") + expect(transaction.span_recorder.spans.count).to eq(2) + + request_span = transaction.span_recorder.spans.last + expect(request_span.op).to eq("net.http") + expect(request_span.start_timestamp).not_to be_nil + expect(request_span.timestamp).not_to be_nil + expect(request_span.start_timestamp).not_to eq(request_span.timestamp) + expect(request_span.description).to eq("GET http://example.com/path") + expect(request_span.data).to eq({ status: 200 }) + end end it "adds sentry-trace header to the request header" do