From 2c93a90b8b3fb850bef0665dc24184b9d25565c9 Mon Sep 17 00:00:00 2001 From: Shawn Poulson Date: Fri, 29 Sep 2023 14:02:03 -0400 Subject: [PATCH] Fix error metric on timeout. --- go.mod | 1 + go.sum | 2 ++ gubernator.go | 13 ++----------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index bb95e40c..53d3075c 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/davecgh/go-spew v1.1.1 github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 github.com/hashicorp/memberlist v0.5.0 + github.com/mailgun/errors v0.1.5 github.com/mailgun/holster/v4 v4.14.2 github.com/miekg/dns v1.1.50 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 41681302..c5b49c1c 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailgun/errors v0.1.5 h1:riRpZqfUKTdc8saXvoEg2tYkbRyZESU1KvQ3UxPbdus= +github.com/mailgun/errors v0.1.5/go.mod h1:lw+Nh4r/aoUTz6uK915FdfZJo3yq60gPiflFHNpK4NQ= github.com/mailgun/holster/v4 v4.14.2 h1:wBS+IufPnQM8EBgQtLf7ywuUmmAnaEdRujul/l7xWY4= github.com/mailgun/holster/v4 v4.14.2/go.mod h1:0Gc8+xqL3ElCsceOt7ySj1J3j9s3WLBJaV07yeE61y4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/gubernator.go b/gubernator.go index 8f24885e..2b4d7671 100644 --- a/gubernator.go +++ b/gubernator.go @@ -23,8 +23,8 @@ import ( "sync" "sync/atomic" + "github.com/mailgun/errors" "github.com/mailgun/holster/v4/ctxutil" - "github.com/mailgun/holster/v4/errors" "github.com/mailgun/holster/v4/setter" "github.com/mailgun/holster/v4/syncutil" "github.com/mailgun/holster/v4/tracing" @@ -763,14 +763,5 @@ func countError(err error, defaultType string) { } func isDeadlineExceeded(err error) bool { - for { - if err == nil { - return false - } - if errors.Is(err, context.DeadlineExceeded) { - return true - } - - err = errors.Unwrap(err) - } + return errors.As(err, context.DeadlineExceeded) }