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:
authorEric Ju <eju@gitlab.com>2023-11-01 23:33:33 +0300
committerEric Ju <eju@gitlab.com>2023-11-01 23:33:33 +0300
commit0dcdb448a6ae6b791d213bba763bc7d27a1d78f5 (patch)
tree203a94a895ddf46667ca84e2743f4f87e477ed59
parentde0c315dcd639a3320eb97103b4c5e41b0466bca (diff)
-rw-r--r--go.mod1
-rw-r--r--go.sum1
-rw-r--r--internal/log/middleware.go13
3 files changed, 15 insertions, 0 deletions
diff --git a/go.mod b/go.mod
index 2fac5b75a..8e8c8c72a 100644
--- a/go.mod
+++ b/go.mod
@@ -19,6 +19,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.1
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
+ github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/hashicorp/yamux v0.1.2-0.20220728231024-8f49b6f63f18
diff --git a/go.sum b/go.sum
index c1f4a053f..495917a88 100644
--- a/go.sum
+++ b/go.sum
@@ -383,6 +383,7 @@ github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7Fsg
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
+github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
diff --git a/internal/log/middleware.go b/internal/log/middleware.go
index 14c53c8fb..42f1a6263 100644
--- a/internal/log/middleware.go
+++ b/internal/log/middleware.go
@@ -2,10 +2,13 @@ package log
import (
"context"
+ "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors"
"regexp"
grpcmwlogging "github.com/grpc-ecosystem/go-grpc-middleware/logging"
grpcmwlogrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
+ "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/selector"
+
"github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/env"
"google.golang.org/grpc"
@@ -40,6 +43,16 @@ func DeciderOption() grpcmwlogrus.Option {
return grpcmwlogrus.WithDecider(decider)
}
+func DeciderMatcher() selector.Matcher {
+ matcher := methodNameMatcherFromEnv()
+ return selector.MatchFunc(func(_ context.Context, callMeta interceptors.CallMeta) bool {
+ if matcher == nil {
+ return true
+ }
+ return matcher(callMeta.FullMethod())
+ })
+}
+
func methodNameMatcherFromEnv() func(string) bool {
if pattern := env.GetString("GITALY_LOG_REQUEST_METHOD_ALLOW_PATTERN",
defaultLogRequestMethodAllowPattern); pattern != "" {