Skip to content

Commit 75f64c6

Browse files
committed
update sample rate in dsc
1 parent 91bf322 commit 75f64c6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

sentry_sdk/scope.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,13 @@ def start_transaction(
10431043
sampling_context.update(custom_sampling_context)
10441044
transaction._set_initial_sampling_decision(sampling_context=sampling_context)
10451045

1046+
# update the sample rate in the dsc
1047+
propagation_context = self.get_active_propagation_context()
1048+
if propagation_context:
1049+
dsc = propagation_context.dynamic_sampling_context
1050+
if dsc is not None:
1051+
dsc["sample_rate"] = str(transaction.sample_rate)
1052+
10461053
if transaction.sampled:
10471054
profile = Profile(
10481055
transaction.sampled, transaction._start_timestamp_monotonic_ns

sentry_sdk/tracing_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def __init__(
378378
self.parent_sampled = parent_sampled
379379
"""Boolean indicator if the parent span was sampled.
380380
Important when the parent span originated in an upstream service,
381-
because we watn to sample the whole trace, or nothing from the trace."""
381+
because we want to sample the whole trace, or nothing from the trace."""
382382

383383
self.dynamic_sampling_context = dynamic_sampling_context
384384
"""Data that is used for dynamic sampling decisions."""

tests/tracing/test_sampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_passes_parent_sampling_decision_in_sampling_context(
211211
assert sampling_context["parent_sampled"]._mock_wraps is parent_sampling_decision
212212

213213

214-
def test_passes_custom_samling_context_from_start_transaction_to_traces_sampler(
214+
def test_passes_custom_sampling_context_from_start_transaction_to_traces_sampler(
215215
sentry_init, DictionaryContaining # noqa: N803
216216
):
217217
traces_sampler = mock.Mock()

0 commit comments

Comments
 (0)