import uuid def gen_trace_id(): return uuid.uuid4().hex def gen_span_id(): random_value = uuid.uuid4().int span_id = "{:016x}".format(random_value % (16 ** 16)) return span_id