Skip to content

Commit 381c41f

Browse files
committed
Types fix, slight optimization
This change because mypy isn't willing to believe the exponent is always positive. See python/typeshed#285.
1 parent bdee2f9 commit 381c41f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

opentelemetry-api/src/opentelemetry/trace/sampling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ def __init__(self, rate: float):
8383
# The sampler checks the 8 high-order bytes of the trace ID to decide
8484
# whether to sample a given trace.
8585
CHECK_HIGH_BITS = 64
86+
TRACE_ID_LIMIT = 2 ** CHECK_HIGH_BITS # type: int
8687

8788
@classmethod
8889
def get_bound_for_rate(cls, rate: float) -> int:
89-
return round(rate * 2 ** cls.CHECK_HIGH_BITS)
90+
return round(rate * cls.TRACE_ID_LIMIT)
9091

9192
@property
9293
def rate(self) -> float:

0 commit comments

Comments
 (0)