Skip to content

Commit

Permalink
Temp: added set_scope logic
Browse files Browse the repository at this point in the history
  • Loading branch information
seyoon-lim committed Aug 13, 2024
1 parent f762f7b commit 6323b2a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sentry_sdk/integrations/spark/spark_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sentry_sdk
from sentry_sdk.integrations import Integration
from sentry_sdk.utils import capture_internal_exceptions, ensure_integration_enabled
from sentry_sdk.scope import Scope

from sentry_sdk._types import TYPE_CHECKING

Expand Down Expand Up @@ -224,10 +225,20 @@ class Java:


class SentryListener(SparkListener):
def _add_breadcrumb(
self,
level, # type: str
message, # type: str
data=None, # type: Optional[dict[str, Any]]
):
# type: (...) -> None
Scope.set_isolation_scope(Scope.get_global_scope())
sentry_sdk.add_breadcrumb(level=level, message=message, data=data)

def onJobStart(self, jobStart): # noqa: N802,N803
# type: (Any) -> None
message = "Job {} Started".format(jobStart.jobId())
sentry_sdk.add_breadcrumb(level="info", message=message)
self._add_breadcrumb(level="info", message=message)
_set_app_properties()

def onJobEnd(self, jobEnd): # noqa: N802,N803
Expand All @@ -243,14 +254,14 @@ def onJobEnd(self, jobEnd): # noqa: N802,N803
level = "warning"
message = "Job {} Failed".format(jobEnd.jobId())

sentry_sdk.add_breadcrumb(level=level, message=message, data=data)
self._add_breadcrumb(level=level, message=message, data=data)

def onStageSubmitted(self, stageSubmitted): # noqa: N802,N803
# type: (Any) -> None
stage_info = stageSubmitted.stageInfo()
message = "Stage {} Submitted".format(stage_info.stageId())
data = {"attemptId": stage_info.attemptId(), "name": stage_info.name()}
sentry_sdk.add_breadcrumb(level="info", message=message, data=data)
self._add_breadcrumb(level="info", message=message, data=data)
_set_app_properties()

def onStageCompleted(self, stageCompleted): # noqa: N802,N803
Expand All @@ -271,4 +282,4 @@ def onStageCompleted(self, stageCompleted): # noqa: N802,N803
message = "Stage {} Completed".format(stage_info.stageId())
level = "info"

sentry_sdk.add_breadcrumb(level=level, message=message, data=data)
self._add_breadcrumb(level=level, message=message, data=data)

0 comments on commit 6323b2a

Please sign in to comment.