Skip to content

Commit be19ff4

Browse files
committed
.
1 parent 34cb097 commit be19ff4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sentry_sdk/integrations/opentelemetry/sampler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def should_sample(
216216
# it in PropagationContext
217217
sample_rand = parent_sample_rand
218218
else:
219-
# There is no sample_rand yet, generate a new one
220-
sample_rand = _generate_sample_rand(str(trace_id), (0, 1))
219+
# We are the head SDK and we need to generate a new sample_rand
220+
sample_rand = cast(Decimal, _generate_sample_rand(str(trace_id), (0, 1)))
221221

222222
# Explicit sampled value provided at start_span
223223
custom_sampled = cast(

sentry_sdk/tracing_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def _generate_sample_rand(
764764
trace_id, # type: Optional[str]
765765
interval=(0.0, 1.0), # type: tuple[float, float]
766766
):
767-
# type: (...) -> decimal.Decimal
767+
# type: (...) -> Optional[decimal.Decimal]
768768
"""Generate a sample_rand value from a trace ID.
769769
770770
The generated value will be pseudorandomly chosen from the provided
@@ -802,7 +802,7 @@ def _sample_rand_range(parent_sampled, sample_rate):
802802

803803

804804
def _round_sample_rand(sample_rand):
805-
# type: (Decimal) -> Optional[Decimal]
805+
# type: (Union[Decimal, float, str]) -> Optional[Decimal]
806806
# Round down to exactly six decimal-digit precision.
807807
# Setting the context is needed to avoid an InvalidOperation exception
808808
# in case the user has changed the default precision.

0 commit comments

Comments
 (0)