관리-도구
편집 파일: monitoring.cpython-38.pyc
U �Mg^ � @ s� d dl Z d dlmZ d dlZd dlmZ d dlmZ d dlmZ d dl m Z e rdd dl mZmZm Z eddd �Zd d� Zdd � Zdd� Zddd�ZdS )� N)�wraps)� start_span)�Span)� ContextVar)� TYPE_CHECKING)�Optional�Callable�Any�ai_pipeline_name)�defaultc C s t �| � d S �N)�_ai_pipeline_name�set)�name� r �F/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/ai/monitoring.py�set_ai_pipeline_name s r c C s t �� S r )r �getr r r r �get_ai_pipeline_name s r c s � �fdd�}|S )Nc sF �� �fdd�}�� �fdd�}t �� �r6t� �|�S t� �|�S d S )Nc sJ t �� }��d|rdnd�}tf � |d������}|�di ��� D ]\}}|�||� qD|�di ��� D ]\}}|�||� qj|r�|�d|� �| |�W 5 Q R � S t �� � znz�| |�}W nZ tk �r } z:t j j|t �� j dd d �d�\} } t j| | d� |d �W 5 d }~X Y nX W 5 t �d � X |W 5 Q R � S W 5 Q R X d S � N�opzai.runzai.pipeline)r r Zsentry_tagsZsentry_data�ai.pipeline.nameZ ai_monitoringF)�typeZhandled)Zclient_optionsZ mechanism)�hint�r r r �pop�itemsZset_tag�set_datar � Exception� sentry_sdk�utilsZevent_from_exceptionZ get_client�optionsZ capture_event��args�kwargsZ curr_pipeliner �span�k�v�res�e�eventr ��description�f�span_kwargsr r �sync_wrapped s. � z1ai_track.<locals>.decorator.<locals>.sync_wrappedc � sV t �� }��d|rdnd�}tf � |d������}|�di ��� D ]\}}|�||� qD|�di ��� D ]\}}|�||� qj|r�|�d|� �| |�I d H W 5 Q R � S t �� � ztz�| |�I d H }W nZ tk �r& } z:t j j|t �� j dd d �d�\} } t j| | d� |d �W 5 d }~X Y nX W 5 t �d � X |W 5 Q R � S W 5 Q R X d S r r r"