Просмотр исходного кода

fSQS-777 write only one log record per SQS request

Writing log about request in SQS only once
sergeyveselov 1 год назад
Родитель
Сommit
a020d30470

+ 1 - 0
ydb/core/ymq/actor/auth_factory.h

@@ -15,6 +15,7 @@ struct TAuthActorData {
 
     THolder<NKikimrClient::TSqsRequest> SQSRequest;
     THolder<IReplyCallback> HTTPCallback;
+    std::function<void(TString)> UserSidCallback;
 
     bool EnableQueueLeader;
 

+ 4 - 1
ydb/core/ymq/actor/auth_multi_factory.cpp

@@ -99,6 +99,7 @@ public:
         , CloudId_(data.CloudID)
         , ResourceId_(data.ResourceID)
         , Counters_(*data.Counters)
+        , UserSidCallback_(std::move(data.UserSidCallback))
     {
         Y_ABORT_UNLESS(RequestId_);
     }
@@ -308,7 +309,7 @@ public:
         }
 
         UserSID_ = result.Token->GetUserSID();
-        LOG_SQS_INFO("Request [" << RequestId_ << "] " << " on queue from subject: " << UserSID_);
+        UserSidCallback_(UserSID_);
         OnFinishedRequest();
     }
 
@@ -558,6 +559,8 @@ private:
     TDuration FolderServiceRequestRetryPeriod_ = CLOUD_AUTH_RETRY_PERIOD;
 
     NKikimrClient::TSqsResponse Response_;
+
+    std::function<void(TString)> UserSidCallback_;
 };
 
 void TMultiAuthFactory::Initialize(

+ 4 - 6
ydb/core/ymq/http/http.cpp

@@ -185,6 +185,9 @@ TString THttpRequest::LogHttpRequestResponseCommonInfoString() {
         logString << " Action [" << ActionToString(Action_) << "]";
     }
     logString << " IP [" << SourceAddress_ << "] Duration [" << duration.MilliSeconds() << "ms]";
+    if (UserSid_) {
+        logString << " Subject [" << UserSid_ << "]";
+    }
     return logString;
 }
 
@@ -230,12 +233,6 @@ bool THttpRequest::DoReply(const TReplyParams& p) {
 
         const TDuration parseTime = TInstant::Now() - StartTime_;
         RLOG_SQS_BASE_DEBUG(*Parent_->ActorSystem_, "Parse time: [" << parseTime.MilliSeconds() << "ms]");
-        RLOG_SQS_BASE_INFO(
-                *Parent_->ActorSystem_,
-                "Start request. User [" << UserName_ << "] Queue [" << QueueName_ << "], Cloud [" << AccountName_
-                       << "], Folder [" << FolderId_ << "] Action [" << ActionToString(Action_)
-                       << "] IP [" << SourceAddress_ << "]"
-        );
 
         if (!Parent_->Config.GetYandexCloudMode() && UserName_.empty()) {
             WriteResponse(p, MakeErrorXmlResponse(NErrors::MISSING_PARAMETER, Parent_->AggregatedUserCounters_.Get(), "No user name was provided."));
@@ -568,6 +565,7 @@ bool THttpRequest::SetupRequest() {
     TAuthActorData data {
         .SQSRequest = std::move(requestHolder),
         .HTTPCallback = std::move(httpCallback),
+        .UserSidCallback = [this](const TString& userSid) { UserSid_ = userSid; },
         .EnableQueueLeader = enableQueueLeader,
         .Action = Action_,
         .ExecutorPoolID = Parent_->PoolId_,

+ 2 - 0
ydb/core/ymq/http/http.h

@@ -133,6 +133,8 @@ private:
 
     bool IsPrivateRequest_ = false; // Has "/private" path prefix
     TInstant StartTime_ = TInstant::Now();
+
+    TString UserSid_;
 };
 
 class TAsyncHttpServer