mirror of
https://github.com/NotAShelf/watchdog.git
synced 2026-04-15 14:54:00 +00:00
api/handler: document request ID size
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia4c92c2e7f3a4d68252a41cf9bc5c9c86a6a6964
This commit is contained in:
parent
c925cca321
commit
5fc6ef592f
1 changed files with 5 additions and 1 deletions
|
|
@ -341,8 +341,12 @@ func (h *IngestionHandler) classifyDevice(width int, userAgent string) string {
|
|||
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 {
|
||||
// 8 bytes = 64 bits = 16 hex chars = 2^64 possible IDs
|
||||
b := make([]byte, 8)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
// Fallback to timestamp if crypto/rand fails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue