Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2022-03-21 18:40:15 +0300
committerJacob Vosmaer <jacob@gitlab.com>2022-03-21 18:40:15 +0300
commit9c9d5c3e8c3822d429d3556488aca091804194de (patch)
tree19f6cc6a5a336a529afe09aee86750ed5bb138ee
parentda590aad2d93420747e4e88d60ec9f9a12f7b734 (diff)
GetArchive: log request hash
This will allow us to determine in the future if it is worth adding a cache for GetArchive.
-rw-r--r--internal/gitaly/service/repository/archive.go16
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[:])
+}