diff options
author | Paul Okstad <pokstad@gitlab.com> | 2020-02-03 22:25:19 +0300 |
---|---|---|
committer | Paul Okstad <pokstad@gitlab.com> | 2020-02-03 22:25:19 +0300 |
commit | 35e5b4a924e9f78cfba0c2e8a44ff3420447cea4 (patch) | |
tree | cb37112fc29f9952c13d9ed4ef9dbd5643b5b3bf | |
parent | 6fbe1c7ea612e438ca30cad7316724f341532e73 (diff) | |
parent | 16900236afb67c947fe69d22fbf89d0c7d883a5d (diff) |
Merge branch 'jc-praefect-correlation-id' into 'master'
Add grpc tag interceptor
See merge request gitlab-org/gitaly!1795
-rw-r--r-- | changelogs/unreleased/jc-praefect-correlation-id.yml | 5 | ||||
-rw-r--r-- | internal/praefect/server.go | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/changelogs/unreleased/jc-praefect-correlation-id.yml b/changelogs/unreleased/jc-praefect-correlation-id.yml new file mode 100644 index 000000000..c57019f69 --- /dev/null +++ b/changelogs/unreleased/jc-praefect-correlation-id.yml @@ -0,0 +1,5 @@ +--- +title: Add grpc tag interceptor +merge_request: 1795 +author: +type: other 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, |