diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,6 @@ # cf T3815 frozendict < 2.1.2 pyld -xmltodict +sentry-sdk typing-extensions +xmltodict \ No newline at end of file diff --git a/swh/indexer/fossology_license.py b/swh/indexer/fossology_license.py --- a/swh/indexer/fossology_license.py +++ b/swh/indexer/fossology_license.py @@ -7,6 +7,8 @@ import subprocess from typing import Any, Dict, Iterable, List, Optional +import sentry_sdk + from swh.core.api.classes import stream_results from swh.core.config import merge_configs from swh.indexer.storage.interface import IndexerStorageInterface, Sha1 @@ -49,6 +51,7 @@ logger.exception( "Problem during license detection for sha1 %s" % __path.basename(path) ) + sentry_sdk.capture_exception() return { "licenses": [], "path": path, diff --git a/swh/indexer/indexer.py b/swh/indexer/indexer.py --- a/swh/indexer/indexer.py +++ b/swh/indexer/indexer.py @@ -23,6 +23,8 @@ ) import warnings +import sentry_sdk + from swh.core import utils from swh.core.config import load_from_envvar, merge_configs from swh.indexer.storage import INDEXER_CFG_KEY, Sha1, get_indexer_storage @@ -331,6 +333,7 @@ if not self.catch_exceptions: raise self.log.exception("Problem when reading contents metadata.") + sentry_sdk.capture_exception() summary["status"] = "failed" return summary @@ -486,6 +489,7 @@ if not self.catch_exceptions: raise self.log.exception("Problem when computing metadata.") + sentry_sdk.capture_exception() summary["status"] = "failed" if count > 0 and count_object_added_key: @@ -547,6 +551,7 @@ results.extend(self.index(origin_url, **kwargs)) except Exception: self.log.exception("Problem when processing origin %s", origin_url) + sentry_sdk.capture_exception() raise return results @@ -598,6 +603,7 @@ if not self.catch_exceptions: raise self.log.exception("Problem when processing revision") + sentry_sdk.capture_exception() summary["status"] = "failed" return summary diff --git a/swh/indexer/metadata.py b/swh/indexer/metadata.py --- a/swh/indexer/metadata.py +++ b/swh/indexer/metadata.py @@ -16,6 +16,8 @@ TypeVar, ) +import sentry_sdk + from swh.core.config import merge_configs from swh.core.utils import grouper from swh.indexer.codemeta import merge_documents @@ -107,6 +109,7 @@ "Problem during metadata translation " "for content %s" % hashutil.hash_to_hex(id) ) + sentry_sdk.capture_exception() if metadata is None: return [] return [ @@ -214,6 +217,7 @@ ) except Exception as e: self.log.exception("Problem when indexing rev: %r", e) + sentry_sdk.capture_exception() return [ RevisionIntrinsicMetadataRow( id=rev.id, @@ -304,6 +308,7 @@ except Exception: self.log.exception("Exception while indexing metadata on contents") + sentry_sdk.capture_exception() metadata = merge_documents(metadata) return (used_mappings, metadata) diff --git a/swh/indexer/rehash.py b/swh/indexer/rehash.py --- a/swh/indexer/rehash.py +++ b/swh/indexer/rehash.py @@ -8,6 +8,8 @@ import logging from typing import Any, Dict, Generator, List, Optional, Tuple +import sentry_sdk + from swh.core import utils from swh.core.config import load_from_envvar from swh.model import hashutil @@ -98,6 +100,7 @@ ) except Exception: self.log.exception("Problem when reading contents metadata.") + sentry_sdk.capture_exception() continue for sha1, content_model in zip(sha1s, content_metadata): @@ -165,6 +168,7 @@ status = "eventful" except Exception: self.log.exception("Problem during update.") + sentry_sdk.capture_exception() continue return {