[#396] Add user to response #396

Merged
alexvanin merged 1 commit from pogpp/frostfs-s3-gw:feature/add_logs_to_request into master 2024-06-04 09:37:56 +00:00
2 changed files with 4 additions and 0 deletions
Showing only changes of commit cbed408670 - Show all commits

View file

@ -42,6 +42,7 @@ func (h *handler) logAndSendError(w http.ResponseWriter, logText string, reqInfo
zap.String("bucket", reqInfo.BucketName), zap.String("bucket", reqInfo.BucketName),
zap.String("object", reqInfo.ObjectName), zap.String("object", reqInfo.ObjectName),
zap.String("description", logText), zap.String("description", logText),
zap.String("user", reqInfo.User),
zap.Error(err)} zap.Error(err)}
fields = append(fields, additional...) fields = append(fields, additional...)
if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() { if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {

View file

@ -328,6 +328,9 @@ func LogSuccessResponse(l *zap.Logger) Func {
if reqInfo.ObjectName != "" { if reqInfo.ObjectName != "" {
fields = append(fields, zap.String("object", reqInfo.ObjectName)) fields = append(fields, zap.String("object", reqInfo.ObjectName))
} }
if reqInfo.User != "" {
fields = append(fields, zap.String("user", reqInfo.User))
dkirillov marked this conversation as resolved Outdated

Do we need the same when request ends with error?

Do we need the same when request ends with error?
Outdated
Review

Do we need the same when request ends with error?

Agree - added

> Do we need the same when request ends with error? Agree - added

I meant just log user in case of request failed (somewhere here) rather than include user info into error response.

I meant just log user in case of request failed (somewhere [here](https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/src/commit/9787b295427034396ed2ead8d0c1687a25beb4ec/api/handler/util.go#L39)) rather than include user info into error response.
Outdated
Review

done

done
}
if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() { if traceID, err := trace.TraceIDFromHex(reqInfo.TraceID); err == nil && traceID.IsValid() {
fields = append(fields, zap.String("trace_id", reqInfo.TraceID)) fields = append(fields, zap.String("trace_id", reqInfo.TraceID))