Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 4df7869

Browse files
authored
dev: Add a couple logs around gql rate limiter (#809)
1 parent 1b37195 commit 4df7869

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

graphql_api/views.py

+12
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,22 @@ def _check_ratelimit(self, request):
325325

326326
current_count = redis.get(key)
327327
if current_count is None:
328+
log.info(
329+
"[GQL Rate Limit] - Setting new key",
330+
extra=dict(key=key, user_id=user_id),
331+
)
328332
redis.setex(key, window, 1)
329333
elif int(current_count) >= limit:
334+
log.warning(
335+
"[GQL Rate Limit] - Rate limit reached for key",
336+
extra=dict(key=key, limit=limit, count=current_count, user_id=user_id),
337+
)
330338
return True
331339
else:
340+
log.warning(
341+
"[GQL Rate Limit] - Incrementing rate limit for key",
342+
extra=dict(key=key, limit=limit, count=current_count, user_id=user_id),
343+
)
332344
redis.incr(key)
333345
return False
334346

0 commit comments

Comments
 (0)