def get_trace_id(request):
if '<STR_LIT>' in request.headers:<EOL><INDENT>trace_id = _convert_signed_hex(request.headers['<STR_LIT>'])<EOL>trace_id = trace_id[-<NUM_LIT:16>:]<EOL><DEDENT>elif '<STR_LIT>' in request.registry.settings:<EOL><INDENT>trace_id = _convert_signed_hex(request.registry.settings[<EOL>'<STR_LIT>'](request))<EOL><DEDENT>else:<EOL><INDENT>trace_id = generate_random_64bit_string()<EOL><DEDENT>return trace_id<EOL>
Gets the trace id based on a request. If not present with the request,
    create a custom (depending on config: `zipkin.trace_id_generator`) or a
    completely random trace id.

    :param: current active pyramid request
    :returns: a 64-bit hex string