Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make default error callback logs more informative #78

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/neptune_scale/core/components/errors_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ def close(self) -> None:


def default_error_callback(error: BaseException, last_seen_at: Optional[float]) -> None:
logger.error(error)
logger.error(f"Terminating the process due to an error: {error}")
kill_me()


def default_network_error_callback(error: BaseException, last_seen_at: Optional[float]) -> None:
logger.warning("Experiencing network issues. Retrying...")
if last_seen_at is None or time.time() - last_seen_at > 5:
logger.warning(f"A network error occurred: {error}. Retrying...")


def default_max_queue_size_exceeded_callback(error: BaseException, last_raised_at: Optional[float]) -> None:
if last_raised_at is None or time.time() - last_raised_at > 5:
logger.warning(error)
logger.warning(f"Pending operations queue size exceeded: {error}. Retrying...")


def default_warning_callback(error: BaseException, last_seen_at: Optional[float]) -> None:
Expand Down Expand Up @@ -114,7 +115,7 @@ def work(self) -> None:
elif isinstance(error, NeptuneAsyncLagThresholdExceeded):
self._on_async_lag_callback()
else:
self._on_error_callback(NeptuneUnexpectedError(reason=str(type(error))), last_raised_at)
self._on_error_callback(NeptuneUnexpectedError(reason=str(error)), last_raised_at)
except Exception as e:
# Don't let user errors kill the process
logger.error(f"An exception occurred in user callback function: {e}")
1 change: 1 addition & 0 deletions src/neptune_scale/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class NeptuneUnexpectedError(NeptuneScaleError):
message = """
{h1}
----NeptuneUnexpectedError-----------------------------------------------------
Reason: `{reason}`
{end}
An unexpected error occurred in the Neptune Scale client. For help, contact support@neptune.ai. Raw exception name: "{reason}"
Expand Down
Loading