13 lines
284 B
Python
13 lines
284 B
Python
from __future__ import annotations
|
|
|
|
import re
|
|
import uuid
|
|
|
|
|
|
REQUEST_ID_PATTERN = re.compile(r"[A-Za-z0-9._-]{8,80}")
|
|
|
|
|
|
def correlation_id(supplied: str = "") -> str:
|
|
value = str(supplied or "").strip()
|
|
return value if REQUEST_ID_PATTERN.fullmatch(value) else uuid.uuid4().hex
|