Skip to content

Commit

Permalink
Add: added add_event_processor method
Browse files Browse the repository at this point in the history
  • Loading branch information
seyoon-lim committed Aug 7, 2024
1 parent 4c673d6 commit 52559be
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions sentry_sdk/integrations/spark/spark_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,21 @@ def _set_app_properties():
)


def _start_sentry_listener():
def _start_sentry_listener(sc):
# type: (Any) -> None
"""
Start java gateway server to add custom `SparkListener`
"""
from pyspark import SparkContext
from pyspark.java_gateway import ensure_callback_server_started

sc = SparkContext._active_spark_context
gw = sc._gateway
ensure_callback_server_started(gw)
listener = SentryListener()
sc._jsc.sc().addSparkListener(listener)


def _activate_integration(sc):
# type: (SparkContext) -> None
from pyspark import SparkContext

_start_sentry_listener()
_set_app_properties()

def _add_event_processor(sc):
# type: (Any) -> None
scope = sentry_sdk.get_isolation_scope()

@scope.add_event_processor
Expand Down Expand Up @@ -92,6 +85,15 @@ def process_event(event, hint):
return event


def _activate_integration(sc):
# type: (SparkContext) -> None
from pyspark import SparkContext

_start_sentry_listener(sc)
_set_app_properties()
_add_event_processor(sc)


def _patch_spark_context_init():
# type: () -> None
from pyspark import SparkContext
Expand All @@ -114,7 +116,6 @@ def _setup_sentry_tracing():

if SparkContext._active_spark_context is not None:
_activate_integration(SparkContext._active_spark_context)
return
_patch_spark_context_init()


Expand Down

0 comments on commit 52559be

Please sign in to comment.