diff options
author | Toon Claes <toon@gitlab.com> | 2022-03-24 13:40:59 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2022-03-24 13:40:59 +0300 |
commit | e302aa4a8caf07caad38c236d610fea49a41aa2f (patch) | |
tree | a09c82cdc0bcfc1596c213f2b9e04b5879c5a361 /internal/gitaly/service | |
parent | 36aaf4e475fdcc4ae89f14772662fa89125d7716 (diff) | |
parent | 9c9d5c3e8c3822d429d3556488aca091804194de (diff) |
Merge branch 'jv-get-archive-request-hash' into 'master'
GetArchive: log request hash
See merge request gitlab-org/gitaly!4425
Diffstat (limited to 'internal/gitaly/service')
-rw-r--r-- | internal/gitaly/service/repository/archive.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/gitaly/service/repository/archive.go b/internal/gitaly/service/repository/archive.go index cffd4fb36..878572f91 100644 --- a/internal/gitaly/service/repository/archive.go +++ b/internal/gitaly/service/repository/archive.go @@ -2,6 +2,8 @@ package repository import ( "context" + "crypto/sha256" + "encoding/hex" "encoding/json" "fmt" "io" @@ -10,6 +12,7 @@ import ( "path/filepath" "strings" + "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus/ctxlogrus" "gitlab.com/gitlab-org/gitaly/v14/internal/command" "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/catfile" @@ -19,6 +22,7 @@ import ( "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/v14/streamio" "gitlab.com/gitlab-org/labkit/correlation" + "google.golang.org/protobuf/proto" ) type archiveParams struct { @@ -92,6 +96,8 @@ func (s *server) GetArchive(in *gitalypb.GetArchiveRequest, stream gitalypb.Repo return err } + ctxlogrus.Extract(ctx).WithField("request_hash", requestHash(in)).Info("request details") + return s.handleArchive(archiveParams{ ctx: ctx, writer: writer, @@ -243,3 +249,13 @@ func (s *server) handleArchive(p archiveParams) error { return archiveCommand.Wait() } + +func requestHash(req proto.Message) string { + reqBytes, err := proto.Marshal(req) + if err != nil { + return "failed to hash request" + } + + hash := sha256.Sum256(reqBytes) + return hex.EncodeToString(hash[:]) +} |