From 5348fcd4d1212afaab2901e83783d899f80f3526 Mon Sep 17 00:00:00 2001
From: Benoit Chauvet <contact@benoitchauvet.com>
Date: Thu, 14 Apr 2022 14:45:54 +0200
Subject: [PATCH] add missing sentry captures

---
 requirements.txt              | 3 ++-
 swh/vault/cookers/base.py     | 2 ++
 swh/vault/cookers/git_bare.py | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/requirements.txt b/requirements.txt
index bbc6f49..9bfddc4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
 click
+fastimport
 flask
 psycopg2
 python-dateutil
-fastimport
+sentry-sdk
 typing-extensions
diff --git a/swh/vault/cookers/base.py b/swh/vault/cookers/base.py
index c96c291..db0b23f 100644
--- a/swh/vault/cookers/base.py
+++ b/swh/vault/cookers/base.py
@@ -10,6 +10,7 @@ import traceback
 from typing import ClassVar, Set
 
 from psycopg2.extensions import QueryCanceledError
+import sentry_sdk
 
 from swh.model.swhids import CoreSWHID, ObjectType
 from swh.storage.interface import StorageInterface
@@ -151,6 +152,7 @@ class BaseVaultCooker(metaclass=abc.ABCMeta):
                 f"The full error was:\n\n{tb}",
             )
             logging.exception("Bundle cooking failed.")
+            sentry_sdk.capture_exception()
         else:
             self.backend.set_status(self.BUNDLE_TYPE, self.swhid, "done")
             self.backend.set_progress(self.BUNDLE_TYPE, self.swhid, None)
diff --git a/swh/vault/cookers/git_bare.py b/swh/vault/cookers/git_bare.py
index 1f76a32..c45b96a 100644
--- a/swh/vault/cookers/git_bare.py
+++ b/swh/vault/cookers/git_bare.py
@@ -42,6 +42,8 @@ import tempfile
 from typing import Any, Dict, Iterable, Iterator, List, NoReturn, Optional, Set, Tuple
 import zlib
 
+import sentry_sdk
+
 from swh.core.api.classes import stream_results_optional
 from swh.model import git_objects
 from swh.model.hashutil import hash_to_bytehex, hash_to_hex
@@ -210,6 +212,7 @@ class GitBareCooker(BaseVaultCooker):
             subprocess.run(["git", "-C", self.gitdir, "repack", "-d"], check=True)
         except subprocess.CalledProcessError:
             logging.exception("git-repack failed with:")
+            sentry_sdk.capture_exception()
 
         # Remove their non-packed originals
         subprocess.run(["git", "-C", self.gitdir, "prune-packed"], check=True)
-- 
GitLab