File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1161,16 +1161,18 @@ def internalerror():
11611161 # TODO: move this to plugins\openlibrary\sentry.py
11621162 from openlibrary .plugins .openlibrary .sentry import sentry
11631163
1164+ event_id : str | None = None
11641165 if sentry .enabled :
1165- sentry .capture_exception_webpy ()
1166+ event_id = sentry .capture_exception_webpy ()
11661167
11671168 if features .is_enabled ('debug' ):
11681169 raise web .debugerror ()
11691170 else :
1171+ name = event_id if event_id else name
11701172 msg = render .site (
11711173 render .internalerror (name , etype = exception_type , evalue = exception_value )
11721174 )
1173- raise web .internalerror (web . safestr ( msg ) )
1175+ raise web .internalerror (msg )
11741176
11751177
11761178delegate .app .internalerror = internalerror
Original file line number Diff line number Diff line change @@ -83,10 +83,14 @@ def capture_exception():
8383 app .internalerror = capture_exception
8484 app .add_processor (WebPySentryProcessor (app ))
8585
86- def capture_exception_webpy (self ):
87- with sentry_sdk .new_scope () as scope :
86+ def capture_exception_webpy (self ) -> str | None :
87+ with sentry_sdk .push_scope () as scope :
8888 scope .add_event_processor (add_web_ctx_to_event )
8989 sentry_sdk .capture_exception ()
90+ transaction = sentry_sdk .get_current_scope ().transaction
91+ trace_id = transaction .trace_id if transaction else None
92+ return trace_id
93+
9094
9195 def capture_exception (self , ex , extras : dict | None = None ):
9296 with sentry_sdk .new_scope () as scope :
You can’t perform that action at this time.
0 commit comments