Skip to content

Commit 948b926

Browse files
committed
.
1 parent 8523fde commit 948b926

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tests/test_dsc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def my_traces_sampler(sampling_context):
413413
if expected_sampled == "tracing-disabled-no-transactions-should-be-sent":
414414
assert len(envelopes) == 0
415415
else:
416+
assert len(envelopes) == 1
416417
transaction_envelope = envelopes[0]
417418
dsc_in_envelope_header = transaction_envelope.headers["trace"]
418419

tests/tracing/test_sampling.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import sentry_sdk
88
from sentry_sdk import start_span, capture_exception
99
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME
10-
from sentry_sdk.tracing_utils import Baggage
1110
from sentry_sdk.utils import logger
1211

1312

@@ -61,7 +60,9 @@ def test_uses_traces_sample_rate_correctly(
6160
sentry_init(traces_sample_rate=traces_sample_rate)
6261

6362
with sentry_sdk.continue_trace(
64-
{BAGGAGE_HEADER_NAME: "sentry-sample_rand=0.500000"}
63+
{
64+
BAGGAGE_HEADER_NAME: "sentry-sample_rand=0.500000,sentry-trace_id=397f36434d07b20135324b2e6ae70c77"
65+
}
6566
):
6667
with start_span(name="dogpark") as root_span:
6768
assert root_span.sampled is expected_decision
@@ -78,9 +79,13 @@ def test_uses_traces_sampler_return_value_correctly(
7879
):
7980
sentry_init(traces_sampler=mock.Mock(return_value=traces_sampler_return_value))
8081

81-
baggage = Baggage(sentry_items={"sample_rand": "0.500000"})
82-
root_span = start_span(name="dogpark", baggage=baggage)
83-
assert root_span.sampled is expected_decision
82+
with sentry_sdk.continue_trace(
83+
{
84+
BAGGAGE_HEADER_NAME: "sentry-sample_rand=0.500000,sentry-trace_id=397f36434d07b20135324b2e6ae70c77"
85+
}
86+
):
87+
with start_span(name="dogpark") as root_span:
88+
assert root_span.sampled is expected_decision
8489

8590

8691
@pytest.mark.parametrize("traces_sampler_return_value", [True, False])

0 commit comments

Comments
 (0)