diff --git a/middleware/throttling.go b/middleware/throttling.go index 8abd3f8..a2e80a8 100644 --- a/middleware/throttling.go +++ b/middleware/throttling.go @@ -5,10 +5,12 @@ import ( "fmt" "net/http" - "github.com/pkg/errors" "isp-gate-service/domain" "isp-gate-service/httperrors" "isp-gate-service/request" + + "github.com/pkg/errors" + "github.com/txix-open/isp-kit/requestid" ) type Throttler interface { @@ -28,10 +30,12 @@ func Throttling(throttler Throttler) Middleware { return errors.WithMessage(err, "throttling: allow rate limit") } if !result.Allow { + requestId := requestid.FromContext(ctx.Context()) return httperrors.New( http.StatusTooManyRequests, fmt.Sprintf("rate limit has been reached, try after %dms", result.RetryAfter.Milliseconds()), - errors.Errorf("throttling: rate limit has been reached for application '%d'", authData.ApplicationId), + errors.Errorf("throttling: rate limit has been reached for application '%d', requestId '%s'", + authData.ApplicationId, requestId), ) }