Skip to content

Commit

Permalink
Airbyte CDK: Log http status code and content in backoff handlers (ai…
Browse files Browse the repository at this point in the history
…rbytehq#8829)

* Log http status code and content in default backoff handler

* Log http status code and content in usef defined backoff handler

* updated cdk version and changelog

* make it clear: exc.response

Co-authored-by: auganbay <auganenu@gmail.com>
  • Loading branch information
augan-rymkhan and Augan93 authored Dec 16, 2021
1 parent 5ac9049 commit 7fbdfc6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.44
Log http response status code and its content.

## 0.1.43
Fix logging of unhandled exceptions: print stacktrace.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
def default_backoff_handler(max_tries: int, factor: int, **kwargs):
def log_retry_attempt(details):
_, exc, _ = sys.exc_info()
if exc.response:
logger.info(f"Status code: {exc.response.status_code}, Response Content: {exc.response.content}")
logger.info(
f"Caught retryable error '{str(exc)}' after {details['tries']} tries. Waiting {details['wait']} seconds then retrying..."
)
Expand Down Expand Up @@ -48,6 +50,8 @@ def user_defined_backoff_handler(max_tries: int, **kwargs):
def sleep_on_ratelimit(details):
_, exc, _ = sys.exc_info()
if isinstance(exc, UserDefinedBackoffException):
if exc.response:
logger.info(f"Status code: {exc.response.status_code}, Response Content: {exc.response.content}")
retry_after = exc.backoff
logger.info(f"Retrying. Sleeping for {retry_after} seconds")
time.sleep(retry_after + 1) # extra second to cover any fractions of second
Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="airbyte-cdk",
version="0.1.43",
version="0.1.44",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 7fbdfc6

Please sign in to comment.