Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 4f143ba

Browse files
authored
Don't use time in trace ID creation (#620)
1 parent 8c8189e commit 4f143ba

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

opencensus/trace/span_context.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import re
1919
import six
2020
import random
21-
import time
2221

2322
from opencensus.trace import trace_options as trace_options_module
2423

@@ -161,12 +160,9 @@ def generate_span_id():
161160

162161

163162
def generate_trace_id():
164-
"""Generate a trace_id randomly. Must be a 32 character
165-
hexadecimal encoded string
163+
"""Generate a random 32 char hex trace_id.
166164
167165
:rtype: str
168166
:returns: 32 digit randomly generated hex trace id.
169167
"""
170-
t = int(time.time())
171-
lower_96 = random.getrandbits(96)
172-
return '{:032x}'.format((t << 96) | lower_96)
168+
return '{:032x}'.format(random.getrandbits(128))

0 commit comments

Comments
 (0)