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>2018-02-21 13:19:47 +0300
committerJacob Vosmaer <jacob@gitlab.com>2018-02-21 13:19:47 +0300
commit75bd9dc0a780eae74f32234871d5abb44be52bdf (patch)
tree4935d8899c8a1d9d3fe93257b056b1c4c6f5e1d5
parentf760a4abace74dc589081aa3df21a4f57fa483fc (diff)
Dont't log InfoRefsUploadPack NotFound to Sentryblacklist-sentry-not-found
-rw-r--r--internal/middleware/sentryhandler/sentryhandler.go26
-rw-r--r--internal/middleware/sentryhandler/sentryhandler_test.go7
2 files changed, 29 insertions, 4 deletions
diff --git a/internal/middleware/sentryhandler/sentryhandler.go b/internal/middleware/sentryhandler/sentryhandler.go
index ee79ea494..b81543b31 100644
--- a/internal/middleware/sentryhandler/sentryhandler.go
+++ b/internal/middleware/sentryhandler/sentryhandler.go
@@ -15,6 +15,15 @@ import (
"google.golang.org/grpc/codes"
)
+// TODO: this blacklist needs to be configurable via config.toml
+var sentryErrorBlacklist = []struct {
+ method string
+ code codes.Code
+}{
+ // Blacklist InfoRefsUploadPack/NotFound because Geo creates lots of bogus wiki clone requests
+ {method: "/gitaly.SmartHTTPService/InfoRefsUploadPack", code: codes.NotFound},
+}
+
// UnaryLogHandler handles access times and errors for unary RPC's
func UnaryLogHandler(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
start := time.Now()
@@ -53,15 +62,24 @@ func methodToCulprit(methodName string) string {
return methodName
}
-func logErrorToSentry(err error) (code codes.Code, bypass bool) {
+func logErrorToSentry(method string, err error) (code codes.Code, bypass bool) {
code = helper.GrpcCode(err)
- bypass = code == codes.OK || code == codes.Canceled
- return code, bypass
+ if code == codes.OK || code == codes.Canceled {
+ return code, true
+ }
+
+ for _, blacklisted := range sentryErrorBlacklist {
+ if method == blacklisted.method && code == blacklisted.code {
+ return code, true
+ }
+ }
+
+ return code, false
}
func generateRavenPacket(ctx context.Context, method string, start time.Time, err error) (*raven.Packet, map[string]string) {
- grpcErrorCode, bypass := logErrorToSentry(err)
+ grpcErrorCode, bypass := logErrorToSentry(method, err)
if bypass {
return nil, nil
}
diff --git a/internal/middleware/sentryhandler/sentryhandler_test.go b/internal/middleware/sentryhandler/sentryhandler_test.go
index b156de474..bd704b391 100644
--- a/internal/middleware/sentryhandler/sentryhandler_test.go
+++ b/internal/middleware/sentryhandler/sentryhandler_test.go
@@ -48,6 +48,13 @@ func Test_generateRavenPacket(t *testing.T) {
err: nil,
wantNil: true,
},
+ {
+ name: "InfoRefsUploadPack not found",
+ method: "/gitaly.SmartHTTPService/InfoRefsUploadPack",
+ sinceStart: 500 * time.Millisecond,
+ err: status.Errorf(codes.NotFound, "Something failed"),
+ wantNil: true,
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {