From c204b787849060760058fa22f651fdc09f2c9dea Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 10 Feb 2026 11:56:50 +0100 Subject: [PATCH 1/2] test: Add test for `get_baggage` with DSN --- tests/test_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index acc33cdf4c..84a568b781 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -22,6 +22,7 @@ ) from sentry_sdk.client import Client, NonRecordingClient +from tests.conftest import TestTransportWithOptions def test_get_current_span(): @@ -96,6 +97,15 @@ def test_baggage_with_tracing_enabled(sentry_init): assert re.match(expected_baggage_re, get_baggage()) +def test_baggage_with_dsn(sentry_init): + sentry_init(dsn="http://97333d956c9e40989a0139756c121c34@sentry-x.sentry-y.s.c.local/976543210", traces_sample_rate=1.0, release="2.0.0", environment="dev", transport=TestTransportWithOptions) + with start_transaction() as transaction: + expected_baggage_re = r"^sentry-trace_id={},sentry-sample_rand=0\.\d{{6}},sentry-environment=dev,sentry-release=2\.0\.0,sentry-public_key=97333d956c9e40989a0139756c121c34,sentry-sample_rate=1\.0,sentry-sampled={}$".format( + transaction.trace_id, "true" if transaction.sampled else "false" + ) + print('xx received baggage', get_baggage() ) + assert re.match(expected_baggage_re, get_baggage()) + def test_continue_trace(sentry_init): sentry_init() From c43841dd5a605e8eb1d3a8f3cd775231a9105e5a Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 10 Feb 2026 13:09:52 +0100 Subject: [PATCH 2/2] format and remove print --- tests/test_api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 84a568b781..bd6b245841 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -98,14 +98,20 @@ def test_baggage_with_tracing_enabled(sentry_init): def test_baggage_with_dsn(sentry_init): - sentry_init(dsn="http://97333d956c9e40989a0139756c121c34@sentry-x.sentry-y.s.c.local/976543210", traces_sample_rate=1.0, release="2.0.0", environment="dev", transport=TestTransportWithOptions) + sentry_init( + dsn="http://97333d956c9e40989a0139756c121c34@sentry-x.sentry-y.s.c.local/976543210", + traces_sample_rate=1.0, + release="2.0.0", + environment="dev", + transport=TestTransportWithOptions, + ) with start_transaction() as transaction: expected_baggage_re = r"^sentry-trace_id={},sentry-sample_rand=0\.\d{{6}},sentry-environment=dev,sentry-release=2\.0\.0,sentry-public_key=97333d956c9e40989a0139756c121c34,sentry-sample_rate=1\.0,sentry-sampled={}$".format( transaction.trace_id, "true" if transaction.sampled else "false" ) - print('xx received baggage', get_baggage() ) assert re.match(expected_baggage_re, get_baggage()) + def test_continue_trace(sentry_init): sentry_init()