Skip to content

Commit

Permalink
feat: Log stream errors (#1686)
Browse files Browse the repository at this point in the history
Co-authored-by: Ken Payne <[email protected]>
  • Loading branch information
edgarrmondragon and Ken Payne authored May 23, 2023
1 parent 9f1a013 commit 0bb5f35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
24 changes: 17 additions & 7 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,9 @@ def sync(self, context: dict | None = None) -> None:
Args:
context: Stream partition or context dictionary.
Raises:
Exception: Any exception raised by the sync process.
"""
msg = f"Beginning {self.replication_method.lower()} sync of '{self.name}'"
if context:
Expand All @@ -1154,13 +1157,20 @@ def sync(self, context: dict | None = None) -> None:
if self.selected:
self._write_schema_message()

batch_config = self.get_batch_config(self.config)
if batch_config:
self._sync_batches(batch_config, context=context)
else:
# Sync the records themselves:
for _ in self._sync_records(context=context):
pass
try:
batch_config = self.get_batch_config(self.config)
if batch_config:
self._sync_batches(batch_config, context=context)
else:
# Sync the records themselves:
for _ in self._sync_records(context=context):
pass
except Exception as ex:
self.logger.exception(
"An unhandled error occurred while syncing '%s'",
self.name,
)
raise ex

def _sync_children(self, child_context: dict | None) -> None:
if child_context is None:
Expand Down
6 changes: 3 additions & 3 deletions singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@ def backoff_handler(self, details: Details) -> None:
https://github.com/litl/backoff#event-handlers
"""
logging.error(
"Backing off %(wait)0.2f seconds after %(tries)d tries "
"calling function %(target)s with args %(args)s and kwargs "
"%(kwargs)s",
"Backing off %0.2f seconds after %d tries "
"calling function %s with args %s and kwargs "
"%s",
details.get("wait"),
details.get("tries"),
details.get("target"),
Expand Down

0 comments on commit 0bb5f35

Please sign in to comment.