import time
import random


def gen_trace_id() -> str:
    """Return 32 random hexadecimal digits.

    The upper 32 bits are the current time in epoch seconds, and the
    lower 96 bits are random. This allows for AWS X-Ray `interop
    <https://github.com/openzipkin/zipkin/issues/1754>`_

    The id is used for distributed tracing.
    """

    high = int(time.time())
    low = random.getrandbits(96)
    return f"{(high << 96) | low:032x}"