diff --git a/swh/loader/package/deposit/loader.py b/swh/loader/package/deposit/loader.py --- a/swh/loader/package/deposit/loader.py +++ b/swh/loader/package/deposit/loader.py @@ -11,6 +11,7 @@ import attr import requests +import sentry_sdk from swh.core.config import load_from_envvar from swh.loader.core.loader import DEFAULT_CONFIG @@ -241,7 +242,8 @@ try: self.metadata() except ValueError: - logger.error(f"Unknown deposit {self.deposit_id}, ignoring") + logger.exception(f"Unknown deposit {self.deposit_id}") + sentry_sdk.capture_exception() return {"status": "failed"} # Then usual loading @@ -289,6 +291,7 @@ ) except Exception: logger.exception("Problem when trying to update the deposit's status") + sentry_sdk.capture_exception() return {"status": "failed"} return r @@ -343,7 +346,6 @@ return r.json() msg = f"Problem when retrieving deposit metadata at {url}" - logger.error(msg) raise ValueError(msg) def status_update( diff --git a/swh/loader/package/loader.py b/swh/loader/package/loader.py --- a/swh/loader/package/loader.py +++ b/swh/loader/package/loader.py @@ -335,9 +335,17 @@ ) } if missing_releases: - logger.error( - "Found ExtIDs pointing to missing releases: %s", missing_releases - ) + + err_message = "Found ExtIDs pointing to missing releases" + + logger.error(err_message + ": %s", missing_releases) + + with sentry_sdk.push_scope() as scope: + scope.set_extra( + "missing_releases", [str(x) for x in missing_releases] + ) + sentry_sdk.capture_message(err_message, "error") + release_extid_targets -= missing_releases extid_target2 = self.select_extid_target(p_info, release_extid_targets) @@ -585,6 +593,7 @@ errors=[str(e)], ) except Exception as e: + sentry_sdk.capture_exception(e) return self.finalize_visit( snapshot=snapshot, visit=visit, @@ -888,7 +897,9 @@ # Deal with extra-branches for name, branch_target in extra_branches.items(): if name in branches: - logger.error("Extra branch '%s' has been ignored", name) + error_message = f"Extra branch '{name!r}' has been ignored" + logger.error(error_message) + sentry_sdk.capture_message(error_message, "error") else: branches[name] = branch_target