diff --git a/sentry-rails/spec/sentry/rails/tracing_spec.rb b/sentry-rails/spec/sentry/rails/tracing_spec.rb index 0bbdb3781..e5c8e68c8 100644 --- a/sentry-rails/spec/sentry/rails/tracing_spec.rb +++ b/sentry-rails/spec/sentry/rails/tracing_spec.rb @@ -185,6 +185,34 @@ expect(transaction.contexts.dig(:trace, :span_id)).not_to eq(external_transaction.span_id) end end + + context "with baggage header" do + let(:baggage_string) do + "other-vendor-value-1=foo;bar;baz, "\ + "sentry-trace_id=771a43a4192642f0b136d5159a501700, "\ + "sentry-public_key=49d0f7386ad645858ae85020e393bef3, "\ + "sentry-sample_rate=0.01337, "\ + "sentry-user_id=Am%C3%A9lie, "\ + "other-vendor-value-2=foo;bar;" + end + + it "has the dynamic_sampling_context on the TransactionEvent" do + expect(Sentry::Transaction).to receive(:new). + with(hash_including(baggage: baggage_string)). + and_call_original + + p = Post.create! + get "/posts/#{p.id}", headers: { "baggage" => baggage_string } + + transaction_event = transport.events.last + expect(transaction_event.dynamic_sampling_context).to eq({ + "sample_rate" => "0.01337", + "public_key" => "49d0f7386ad645858ae85020e393bef3", + "trace_id" => "771a43a4192642f0b136d5159a501700", + "user_id" => "Amélie" + }) + end + end end context "without traces_sample_rate set" do diff --git a/sentry-ruby/spec/sentry/rack/capture_exceptions_spec.rb b/sentry-ruby/spec/sentry/rack/capture_exceptions_spec.rb index 383268378..23cdde8e1 100644 --- a/sentry-ruby/spec/sentry/rack/capture_exceptions_spec.rb +++ b/sentry-ruby/spec/sentry/rack/capture_exceptions_spec.rb @@ -409,16 +409,13 @@ def will_be_sampled_by_sdk let(:transaction_event) { last_sentry_event } - it "passes in baggage header to transaction" do + it "has the dynamic_sampling_context on the TransactionEvent" do expect(Sentry::Transaction).to receive(:new). with(hash_including(baggage: baggage_string)). and_call_original stack.call(env) - end - it "has the dynamic_sampling_context on the TransactionEvent" do - stack.call(env) expect(transaction_event.dynamic_sampling_context).to eq({ "sample_rate" => "0.01337", "public_key" => "49d0f7386ad645858ae85020e393bef3", @@ -426,7 +423,6 @@ def will_be_sampled_by_sdk "user_id" => "Amélie" }) end - end context "when the transaction is sampled" do