From d7d80393c32f4d577fb234490c69bf5e85c812e7 Mon Sep 17 00:00:00 2001 From: Sean Reilly Date: Fri, 15 Nov 2024 06:20:15 -0800 Subject: [PATCH] add some logging so it is easier to see what grpc rate limits are set (#1045) Co-authored-by: Sean Reilly --- internal/services/grpc/middleware/rate_limit.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/services/grpc/middleware/rate_limit.go b/internal/services/grpc/middleware/rate_limit.go index 4842c807d..648cd67d9 100644 --- a/internal/services/grpc/middleware/rate_limit.go +++ b/internal/services/grpc/middleware/rate_limit.go @@ -44,6 +44,7 @@ func (rl *HatchetRateLimiter) GetOrCreateTenantRateLimiter(rateLimitToken string } func NewHatchetRateLimiter(r rate.Limit, b int, l *zerolog.Logger) *HatchetRateLimiter { + l.Info().Msgf("grpc rate limit set to %v per second with a burst of %v (10X rate for Dispatcher)", r, b) return &HatchetRateLimiter{ rateLimiters: make(map[string]*HatchetApiTokenRateLimiter), rate: r, @@ -69,19 +70,19 @@ func (r *HatchetRateLimiter) Limit(ctx context.Context) error { case "dispatcher": if !r.GetOrCreateTenantRateLimiter(rateLimitToken).dispatcherLimiter.Allow() { - r.l.Info().Msg("dispatcher rate limit exceeded") + r.l.Info().Msgf("dispatcher rate limit (%v per second) exceeded", r.GetOrCreateTenantRateLimiter(rateLimitToken).dispatcherLimiter.Limit()) return status.Errorf(codes.ResourceExhausted, "dispatcher rate limit exceeded") } case "events": if !r.GetOrCreateTenantRateLimiter(rateLimitToken).eventsLimiter.Allow() { - r.l.Info().Msg("ingest rate limit exceeded") + r.l.Info().Msgf("ingest rate limit (%v per second) exceeded", r.GetOrCreateTenantRateLimiter(rateLimitToken).eventsLimiter.Limit()) return status.Errorf(codes.ResourceExhausted, "ingest rate limit exceeded") } case "workflow": if !r.GetOrCreateTenantRateLimiter(rateLimitToken).workflowLimiter.Allow() { - r.l.Info().Msg("workflow rate limit exceeded") + r.l.Info().Msgf("workflow rate limit (%v per second) exceeded", r.GetOrCreateTenantRateLimiter(rateLimitToken).workflowLimiter.Limit()) return status.Errorf(codes.ResourceExhausted, "admin rate limit exceeded") }