fix: log retry count at INFO level (#2404)#3072
fix: log retry count at INFO level (#2404)#3072kevinmalana wants to merge 1 commit intoopenai:mainfrom
Conversation
Replace debug-only 'X retries left' logs with a single INFO-level log that includes the retry count (retries_taken) and max_retries in the existing 'Retrying request to ...' message. No increase in log verbosity, just richer context at INFO level.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0aa86ad08f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| timeout = self._calculate_retry_timeout(remaining_retries, options, response.headers if response else None) | ||
| log.info("Retrying request to %s in %f seconds", options.url, timeout) | ||
| log.info("Retrying request to %s in %f seconds (retry %d of %d)", options.url, timeout, retries_taken, max_retries) |
There was a problem hiding this comment.
Report the next retry attempt, not completed retries
This log message is off by one because _sleep_for_retry() is called before the next attempt starts, but it prints retries_taken (the number of retries already completed). On the first retry path (retries_taken == 0), users will see retry 0 of N, and the final retry is logged as retry N-1 of N, which makes the new INFO-level retry counter misleading for troubleshooting in both sync and async clients. Log retries_taken + 1 (or equivalent) to reflect the retry that is about to happen.
Useful? React with 👍 / 👎.
Fixes #2404
Replace debug-only
X retries leftlogs with a single INFO-level log that includesretry N of Min the existingRetrying request to ...message. No increase in log verbosity — same INFO call, richer context.Changes
_sleep_for_retry()(sync): upgradedlog.info()to includeretries_takenandmax_retries_sleep_for_retry()(async): same changelog.debug("1 retry left")/log.debug("X retries left")callsBoth methods updated, covering both sync and async client paths.