File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 11import contextlib
22import inspect
3- import math
43import os
54import re
65import sys
@@ -867,13 +866,9 @@ def _generate_sample_rand(
867866 raise ValueError ("Invalid interval: lower must be less than upper" )
868867
869868 rng = Random (trace_id )
870- sample_rand = upper
871- while sample_rand >= upper :
872- sample_rand = rng .uniform (lower , upper )
869+ sample_rand_scaled = rng .randrange (int (lower * 1000000 ), int (upper * 1000000 ))
873870
874- # Round down to exactly six decimal-digit precision.
875- # Using floor to ensure we always round down, similar to ROUND_DOWN
876- return math .floor (sample_rand * 1000000 ) / 1000000
871+ return sample_rand_scaled / 1000000
877872
878873
879874def _sample_rand_range (parent_sampled , sample_rate ):
Original file line number Diff line number Diff line change @@ -1935,6 +1935,9 @@ def try_convert(convert_func, value):
19351935 given function. Return None if the conversion fails, i.e. if the function
19361936 raises an exception.
19371937 """
1938+ if isinstance (value , convert_func ):
1939+ return value
1940+
19381941 try :
19391942 return convert_func (value )
19401943 except Exception :
You can’t perform that action at this time.
0 commit comments