From 954a30afdae99c0fb5b7f69179a8b6862c6d7d40 Mon Sep 17 00:00:00 2001 From: Brian Kubisiak Date: Fri, 17 Oct 2025 06:17:55 -0700 Subject: [PATCH] github: Log graphql ratelimit for debug Ratelimit information is already available in the HTTP response headers for graphql requests; log this information for debug. Signed-off-by: Brian Kubisiak --- revup/github_real.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/revup/github_real.py b/revup/github_real.py index 0854b62..b9b2e04 100644 --- a/revup/github_real.py +++ b/revup/github_real.py @@ -1,3 +1,4 @@ +import datetime import json import logging import time @@ -74,6 +75,17 @@ async def graphql(self, query: str, **kwargs: Any) -> Any: logging.debug( "Response status: {} took {}".format(resp.status, time.time() - start_time) ) + ratelimit_reset = resp.headers.get("x-ratelimit-reset") + if ratelimit_reset is not None: + reset_timestamp = datetime.datetime.fromtimestamp(int(ratelimit_reset)).isoformat() + else: + reset_timestamp = "Unknown" + logging.debug( + "Ratelimit: {} remaining, resets at {}".format( + resp.headers.get("x-ratelimit-remaining"), + reset_timestamp, + ) + ) try: r = await resp.json() except (ValueError, ContentTypeError):