32 lowercase hex characters
generateTraceId(); // '4bf92f3577b34da6a3ce929d0e0e4736'
export function generateTraceId(): string {
const bytes = crypto.getRandomValues(new Uint8Array(16));
const id = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
// An all-zero id is invalid in OpenTelemetry (a 1-in-2^128 chance, but cheap to rule out).
return TRACE_ID_PATTERN.test(id) ? id : generateTraceId();
}
Generates a random OpenTelemetry trace id, used to tie together every log from one search. It carries no information about the user or the query.