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:
authorJohn Cai <jcai@gitlab.com>2020-01-31 02:53:18 +0300
committerJohn Cai <jcai@gitlab.com>2020-01-31 09:29:12 +0300
commit16900236afb67c947fe69d22fbf89d0c7d883a5d (patch)
tree29bd4b6bb09aa80635799591ab2e1da8207ae439 /internal/praefect/server.go
parent9c12e4566627e19ff33726bbd4da71b4eeac70bc (diff)
Add grpc tag interceptor
Diffstat (limited to 'internal/praefect/server.go')
-rw-r--r--internal/praefect/server.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/praefect/server.go b/internal/praefect/server.go
index de23ceefe..ceb1b8a76 100644
--- a/internal/praefect/server.go
+++ b/internal/praefect/server.go
@@ -8,8 +8,10 @@ import (
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
+ grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/internal/helper/fieldextractors"
"gitlab.com/gitlab-org/gitaly/internal/middleware/cancelhandler"
"gitlab.com/gitlab-org/gitaly/internal/middleware/metadatahandler"
"gitlab.com/gitlab-org/gitaly/internal/middleware/panichandler"
@@ -59,10 +61,16 @@ func (srv *Server) warnDupeAddrs(c config.Config) {
// NewServer returns an initialized praefect gPRC proxy server configured
// with the provided gRPC server options
func NewServer(c *Coordinator, repl ReplMgr, grpcOpts []grpc.ServerOption, l *logrus.Entry, clientConnections *conn.ClientConnections, conf config.Config) *Server {
+ ctxTagOpts := []grpc_ctxtags.Option{
+ grpc_ctxtags.WithFieldExtractorForInitialReq(fieldextractors.FieldExtractor),
+ }
+
grpcOpts = append(grpcOpts, proxyRequiredOpts(c.streamDirector)...)
grpcOpts = append(grpcOpts, []grpc.ServerOption{
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
+ grpc_ctxtags.StreamServerInterceptor(ctxTagOpts...),
grpccorrelation.StreamServerCorrelationInterceptor(), // Must be above the metadata handler
+ metadatahandler.StreamInterceptor,
grpc_prometheus.StreamServerInterceptor,
grpc_logrus.StreamServerInterceptor(l),
sentryhandler.StreamLogHandler,
@@ -74,6 +82,7 @@ func NewServer(c *Coordinator, repl ReplMgr, grpcOpts []grpc.ServerOption, l *lo
panichandler.StreamPanicHandler,
)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
+ grpc_ctxtags.UnaryServerInterceptor(ctxTagOpts...),
grpccorrelation.UnaryServerCorrelationInterceptor(), // Must be above the metadata handler
metadatahandler.UnaryInterceptor,
grpc_prometheus.UnaryServerInterceptor,