관리-도구
편집 파일: gcp.cpython-38.pyc
U �Mg^ � @ sJ d dl Z d dlZd dlmZ d dlmZmZmZ d dlmZ d dl Z d dl mZ d dlm Z d dlmZ d dlmZ d d lmZ d d lmZ d dlmZmZmZmZmZmZ d dlmZ d ZdZ e�rd dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dl%m&Z&m'Z'm(Z( e"de#de!f d�Z)dd� Z*G dd� de�Z+dd� Z,dd� Z-dS )� N)�deepcopy)�datetime� timedelta�timezone)�environ)�continue_trace)�OP)�Integration)�_filter_headers)�should_send_default_pii)�TRANSACTION_SOURCE_COMPONENT)�AnnotatedValue�capture_internal_exceptions�event_from_exception�logger� TimeoutThread�reraise)� TYPE_CHECKINGg �?g @�@)�Any)�TypeVar)�Callable)�Optional)�EventProcessor�Event�Hint�F.)�boundc s t �� �� fdd��}|S )Nc s t �� }|�t�}|d kr,� | |f|�|�S t�d�}|sVt�d� � | |f|�|�S t|�}t � tj�}t � � ���}t� �^ |�� |�t|||�� |�dt�d�� d } |jr�|tkr�|t } t| |�} | �� W 5 Q R X i }t|d�r�|j}t|tjt�dd�ttjd�}t�d�t�d �t�d �t�d�t�d�d�|d �} t j|| d��� z�z0� | |f|�|�W W �lW 5 Q R � W 5 Q R � S t!k �r� t"�#� }t$||j%ddd�d�\}}t j&||d� t'|� Y nX W 5 | �r�| �� |� � X W 5 Q R X W 5 Q R X d S )NZFUNCTION_TIMEOUT_SECzOThe configured timeout could not be fetched from Cloud Functions configuration.Z gcp_region�FUNCTION_REGION�headers� FUNCTION_NAME� )�op�name�source�origin�ENTRY_POINT�FUNCTION_IDENTITY�GCP_PROJECT)� function_name�function_entry_point�function_identity�function_region�function_project)Zgcp_env� gcp_event)Zcustom_sampling_context�gcpF)�typeZhandled)Zclient_optionsZ mechanism)�hint)(� sentry_sdkZ get_clientZget_integration�GcpIntegrationr �getr �debug�intr �nowr �utcZisolation_scoper Zclear_breadcrumbsZadd_event_processor�_make_request_event_processorZset_tag�timeout_warning�TIMEOUT_WARNING_BUFFERr �start�hasattrr r r ZFUNCTION_GCPr r$ Zstart_transaction�stop�flush� Exception�sys�exc_infor �optionsZ capture_eventr )Zfunctionhandlerr- �args�kwargs�clientZintegrationZconfigured_time�initial_time�scopeZtimeout_threadZwaiting_timer ZtransactionZsampling_contextrA Zsentry_eventr0 ��func� �I/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/gcp.py�sentry_func* s� � ���� � �� �0� z_wrap_func.<locals>.sentry_func)� functools�wraps)rI rL rJ rH rK � _wrap_func( s QrO c @ s0 e Zd ZdZde� �Zd dd�Zedd� �ZdS ) r2 r. zauto.function.Fc C s || _ d S )N)r9 )�selfr9 rJ rJ rK �__init__� s zGcpIntegration.__init__c C s: dd l } t| d�s t�d� d S | j}t|jj�|j_d S )Nr � worker_v1zFGcpIntegration currently supports only Python 3.7 runtime environment.)�__main__r<