Feat: timeout and retries#5
Merged
Merged
Conversation
- Added logging for API calls, including method, endpoint path, status code, and duration. - Introduced slow request detection, logging calls taking >= 2000ms at WARNING level. - Made slow threshold configurable via `slow_threshold_ms` parameter in `Weclapp.__init__()`. - Ensured query parameters are stripped from logged paths for security.
…o/weclappy into feat-timeout-and-retries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Default request timeout (120s): All HTTP requests now have a 120-second timeout by default (via DEFAULT_REQUEST_TIMEOUT), aligned with weclapp's recommendation of at least one minute. This covers both _send_request() and the direct count endpoint call in threaded get_all. Callers can still override per-request.
429 retry with exponential backoff: Added HTTP 429 (Too Many Requests) to the existing urllib3 Retry status_forcelist alongside 5xx errors. Uses the new DEFAULT_BACKOFF_FACTOR (0.3s) constant for exponential backoff. Retry-After headers are respected by default.
Request timing logging: Every API call now logs method, endpoint path, status code, and duration in milliseconds. Requests taking >= 2000ms log at WARNING level with [API_SLOW] prefix; others log at INFO with [API] prefix. The slow threshold is configurable via slow_threshold_ms in the constructor. Query parameters are stripped from logged paths for security.