11import sentry_sdk
22from sentry_sdk .integrations import Integration
33from sentry_sdk .utils import capture_internal_exceptions , ensure_integration_enabled
4+ from sentry_sdk .scope import Scope
45
56from sentry_sdk ._types import TYPE_CHECKING
67
@@ -224,10 +225,20 @@ class Java:
224225
225226
226227class SentryListener (SparkListener ):
228+ def _add_breadcrumb (
229+ self ,
230+ level , # type: str
231+ message , # type: str
232+ data = None , # type: Optional[dict[str, Any]]
233+ ):
234+ # type: (Any) -> None
235+ Scope .set_isolation_scope (Scope .get_global_scope ())
236+ sentry_sdk .add_breadcrumb (level = level , message = message , data = data )
237+
227238 def onJobStart (self , jobStart ): # noqa: N802,N803
228239 # type: (Any) -> None
229240 message = "Job {} Started" .format (jobStart .jobId ())
230- sentry_sdk . add_breadcrumb (level = "info" , message = message )
241+ self . _add_breadcrumb (level = "info" , message = message )
231242 _set_app_properties ()
232243
233244 def onJobEnd (self , jobEnd ): # noqa: N802,N803
@@ -243,14 +254,14 @@ def onJobEnd(self, jobEnd): # noqa: N802,N803
243254 level = "warning"
244255 message = "Job {} Failed" .format (jobEnd .jobId ())
245256
246- sentry_sdk . add_breadcrumb (level = level , message = message , data = data )
257+ self . _add_breadcrumb (level = level , message = message , data = data )
247258
248259 def onStageSubmitted (self , stageSubmitted ): # noqa: N802,N803
249260 # type: (Any) -> None
250261 stage_info = stageSubmitted .stageInfo ()
251262 message = "Stage {} Submitted" .format (stage_info .stageId ())
252263 data = {"attemptId" : stage_info .attemptId (), "name" : stage_info .name ()}
253- sentry_sdk . add_breadcrumb (level = "info" , message = message , data = data )
264+ self . _add_breadcrumb (level = "info" , message = message , data = data )
254265 _set_app_properties ()
255266
256267 def onStageCompleted (self , stageCompleted ): # noqa: N802,N803
@@ -271,4 +282,4 @@ def onStageCompleted(self, stageCompleted): # noqa: N802,N803
271282 message = "Stage {} Completed" .format (stage_info .stageId ())
272283 level = "info"
273284
274- sentry_sdk . add_breadcrumb (level = level , message = message , data = data )
285+ self . _add_breadcrumb (level = level , message = message , data = data )
0 commit comments