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:
authorjramsay <jcai@gitlab.com>2019-10-23 01:22:11 +0300
committerJohn Cai <jcai@gitlab.com>2019-10-25 19:54:31 +0300
commit12bcf71ddae2f049d8a998cbaef68f3c7ab9f68a (patch)
tree2d60b920f5e6be81ade1a80d2319bd6df13f9824
parent50c9942e60aa02dbc708be09588b56b59cc7c0d3 (diff)
Log PostUploadPack request sha and response size
-rw-r--r--internal/service/smarthttp/upload_pack.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/service/smarthttp/upload_pack.go b/internal/service/smarthttp/upload_pack.go
index 559d0a2a6..569a2b30b 100644
--- a/internal/service/smarthttp/upload_pack.go
+++ b/internal/service/smarthttp/upload_pack.go
@@ -1,8 +1,11 @@
package smarthttp
import (
+ "crypto/sha1"
+ "fmt"
"io"
+ grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
"github.com/prometheus/client_golang/prometheus"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/git"
@@ -39,10 +42,14 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS
return err
}
- stdinReader := streamio.NewReader(func() ([]byte, error) {
+ h := sha1.New()
+
+ stdinReader := io.TeeReader(streamio.NewReader(func() ([]byte, error) {
resp, err := stream.Recv()
+
return resp.GetData(), err
- })
+ }), h)
+
pr, pw := io.Pipe()
defer pw.Close()
stdin := io.TeeReader(stdinReader, pw)
@@ -51,7 +58,10 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS
deepenCh <- scanDeepen(pr)
}()
+ var respBytes int64
+
stdout := streamio.NewWriter(func(p []byte) error {
+ respBytes += int64(len(p))
return stream.Send(&gitalypb.PostUploadPackResponse{Data: p})
})
@@ -94,6 +104,8 @@ func (s *server) PostUploadPack(stream gitalypb.SmartHTTPService_PostUploadPackS
return status.Errorf(codes.Unavailable, "PostUploadPack: %v", err)
}
+ grpc_logrus.Extract(ctx).WithField("request_sha", fmt.Sprintf("%x", h.Sum(nil))).WithField("response_bytes", respBytes).Info("request details")
+
return nil
}