관리-도구
편집 파일: spark_driver.cpython-37.pyc
B T a! � @ s� d dl mZ d dlmZ d dlmZ d dlmZ d dlm Z e rhd dl mZ d dl mZ d dlm Z mZ G d d � d e�Zdd� Zd d� Zdd� ZG dd� de�ZG dd� de�ZdS )� )�configure_scope)�Hub)�Integration)�capture_internal_exceptions)�MYPY)�Any)�Optional)�Event�Hintc @ s e Zd ZdZedd� �ZdS )�SparkIntegrationZsparkc C s t � d S )N)�patch_spark_context_init� r r �[/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/integrations/spark/spark_driver.py� setup_once s zSparkIntegration.setup_onceN)�__name__� __module__�__qualname__� identifier�staticmethodr r r r r r s r c C s6 ddl m} | j}|r2|�d|j� |�d|j� dS )z� Set properties in driver that propagate to worker processes, allowing for workers to have access to those properties. This allows worker integration to have access to app_name and application_id. r )�SparkContextZsentry_app_nameZsentry_application_idN)�pysparkr Z_active_spark_contextZsetLocalProperty�appName� applicationId)r Z spark_contextr r r �_set_app_properties s r c C s4 ddl m} | j}||� t� }| j�� �|� dS )zA Start java gateway server to add custom `SparkListener` r )�ensure_callback_server_startedN)Zpyspark.java_gatewayr Z_gateway�SentryListenerZ_jsc�scZaddSparkListener)r r ZgwZlistenerr r r �_start_sentry_listener( s r c s( ddl m} | j� � fdd�}|| _d S )Nr )r c sZ �� f|�|�}t j�t�d kr$|S t� � t� t� �}|j� fdd��}W d Q R X |S )Nc s t � �� tj�t�d kr| S | �di ��d� �� � | �di ��d� j�d�� | d �d� j�d�� | d �d� j�d �� | d �d � j�d�� | d �d� j � | d �d � j � | d �d� j� | d �d� j� | d �d� j � | �di ��d� j� W d Q R X | S )N�user�idZtagszexecutor.idzspark.executor.idzspark-submit.deployModezspark.submit.deployModezdriver.hostzspark.driver.hostzdriver.portzspark.driver.portZ spark_versionZapp_nameZapplication_id�masterZ spark_home�extraZweb_url)r r �current�get_integrationr � setdefaultZ sparkUserZ_conf�get�versionr r r Z sparkHomeZuiWebUrl)�event�hint)�selfr r � process_eventG s( z[patch_spark_context_init.<locals>._sentry_patched_spark_context_init.<locals>.process_event)r r"