From ee48d1dc8503f8a9c0747465a85bd8cc218f8393 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Thu, 29 Feb 2024 17:55:25 +0300 Subject: [PATCH] [#325] Log error on failed request id generation Signed-off-by: Denis Kirillov --- api/middleware/reqinfo.go | 5 ++++- internal/logs/logs.go | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/middleware/reqinfo.go b/api/middleware/reqinfo.go index 3a0d0933..9e55471b 100644 --- a/api/middleware/reqinfo.go +++ b/api/middleware/reqinfo.go @@ -198,7 +198,10 @@ func Request(log *zap.Logger, settings RequestSettings) Func { return func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // generate random UUIDv4 - id, _ := uuid.NewRandom() + id, err := uuid.NewRandom() + if err != nil { + log.Error(logs.FailedToGenerateRequestID, zap.Error(err)) + } // set request id into response header // also we have to set request id here diff --git a/internal/logs/logs.go b/internal/logs/logs.go index c4da907c..1e60ac57 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -141,11 +141,10 @@ const ( CouldntDeleteObjectFromStorageContinueDeleting = "couldn't delete object from storage, continue deleting from tree" CouldntPutAccessBoxIntoCache = "couldn't put accessbox into cache" InvalidAccessBoxCacheRemovingCheckInterval = "invalid accessbox check removing interval, using default value" - CouldNotParseContainerAPEEnabledAttribute = "could not parse container APE enabled attribute" CouldNotCloseRequestBody = "could not close request body" BucketOwnerKeyIsMissing = "bucket owner key is missing" SettingsNodeInvalidOwnerKey = "settings node: invalid owner key" - FailedToSendTransaction = "failed to send transaction" SuccessfulAuth = "successful auth" PolicyRequest = "policy request" + FailedToGenerateRequestID = "failed to generate request id" )