Skip to content

Commit

Permalink
Types fix, slight optimization
Browse files Browse the repository at this point in the history
This change because mypy isn't willing to believe the exponent is always
positive. See python/typeshed#285.
  • Loading branch information
c24t committed Oct 25, 2019
1 parent bdee2f9 commit 381c41f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opentelemetry-api/src/opentelemetry/trace/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def __init__(self, rate: float):
# The sampler checks the 8 high-order bytes of the trace ID to decide
# whether to sample a given trace.
CHECK_HIGH_BITS = 64
TRACE_ID_LIMIT = 2 ** CHECK_HIGH_BITS # type: int

@classmethod
def get_bound_for_rate(cls, rate: float) -> int:
return round(rate * 2 ** cls.CHECK_HIGH_BITS)
return round(rate * cls.TRACE_ID_LIMIT)

@property
def rate(self) -> float:
Expand Down

0 comments on commit 381c41f

Please sign in to comment.