@@ -59,6 +59,7 @@ def create_app_context():
5959
6060logger = get_task_logger (__name__ )
6161
62+
6263class ArchiverSizeExceeded (Exception ):
6364
6465 def __init__ (self , result ):
@@ -88,12 +89,13 @@ class ArchiverTask(celery.Task):
8889
8990 def on_failure (self , exc , task_id , args , kwargs , einfo ):
9091 job = ArchiveJob .load (kwargs .get ('job_pk' ))
92+ compact_traceback = utils .compact_traceback (einfo )
9193 if not job :
9294 archiver_state_exc = ArchiverStateError ({
9395 'exception' : exc ,
9496 'args' : args ,
9597 'kwargs' : kwargs ,
96- 'einfo' : einfo ,
98+ 'einfo' : compact_traceback ,
9799 })
98100 sentry .log_exception (archiver_state_exc )
99101 raise archiver_state_exc
@@ -102,7 +104,7 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
102104 # already captured
103105 return
104106
105- src , dst , user = job .info ()
107+ src , dst , _ = job .info ()
106108 errors = []
107109 if isinstance (exc , ArchiverSizeExceeded ):
108110 dst .archive_status = ARCHIVER_SIZE_EXCEEDED
@@ -122,15 +124,23 @@ def on_failure(self, exc, task_id, args, kwargs, einfo):
122124 }
123125 else :
124126 dst .archive_status = ARCHIVER_UNCAUGHT_ERROR
125- errors = [str (einfo )] if einfo else []
127+ errors = [f'{ exc .__class__ .__name__ } : { exc } ' ]
128+ if compact_traceback :
129+ errors .append (f'Traceback tail:\n { compact_traceback } ' )
126130 dst .save ()
127131
132+ # Always capture full exception; keep log_message payload compact.
133+ sentry .log_exception (exc )
128134 sentry .log_message (
129135 f'An error occurred while archiving node: { src ._id } and registration: { dst ._id } ' ,
130136 extra_data = {
131137 'source node guid' : src ._id ,
132138 'registration node guid' : dst ._id ,
133139 'task_id' : task_id ,
140+ 'task_name' : self .name ,
141+ 'exception_type' : exc .__class__ .__name__ ,
142+ 'exception_message' : str (exc ),
143+ 'traceback_tail' : compact_traceback ,
134144 'errors' : errors ,
135145 },
136146 )
0 commit comments