api/handler: document request ID size

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia4c92c2e7f3a4d68252a41cf9bc5c9c86a6a6964
This commit is contained in:
raf 2026-03-10 11:27:20 +03:00
commit 5fc6ef592f
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -341,8 +341,12 @@ func (h *IngestionHandler) classifyDevice(width int, userAgent string) string {
return "unknown" return "unknown"
} }
// generateRequestID creates a unique request ID for tracing // Creates a unique request ID for tracing.
// Uses 8 bytes (64 bits) of randomness which produces 16 hex characters.
// 2^64 possible IDs (~18 quintillion) provides sufficient uniqueness for
// request tracing while keeping IDs reasonably short in logs and headers.
func generateRequestID() string { func generateRequestID() string {
// 8 bytes = 64 bits = 16 hex chars = 2^64 possible IDs
b := make([]byte, 8) b := make([]byte, 8)
if _, err := rand.Read(b); err != nil { if _, err := rand.Read(b); err != nil {
// Fallback to timestamp if crypto/rand fails // Fallback to timestamp if crypto/rand fails