관리-도구
편집 파일: server.cpython-38.pyc
U �Mg� � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZm Z d dl mZ d dlm Z e rxd dlmZmZ d d lmZmZ z,d dlZd d lmZmZ d dlmZmZ W n ek r� ed��Y nX G d d� dejj�ZdS )� N)�OP)�DidNotEnable)�SPAN_ORIGIN)�Transaction�TRANSACTION_SOURCE_CUSTOM)�event_from_exception)� TYPE_CHECKING)� Awaitable�Callable)�Any�Optional)�HandlerCallDetails�RpcMethodHandler)� AbortError�ServicerContextzgrpcio is not installedc s. e Zd Zd� fdd� Zdd� Zdd� Z� ZS ) �ServerInterceptorNc s |p| j | _t� �� d S �N)� _find_name�_find_method_name�super�__init__)�selfZ find_name�� __class__� �U/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/grpc/aio/server.pyr s zServerInterceptor.__init__c � s� |�_ ||�I d H � � d kr d S � jsB� jsBtj}� �fdd�}n^� jsb� jrbtj}� fdd�}n>� jr�� js�tj}� fdd�}n� jr�� jr�tj}� fdd�}||� j� j d�S )Nc � s� �� |�}|s� | |�I d H S tjt|�� �tj|ttd�}t j |d��� z � �| |�I d H W W 5 Q R � S tk r� � Y nH t k r� } z*t|ddd�d�\}}t j||d� � W 5 d }~X Y nX W 5 Q R X d S )N)�op�name�source�origin)�transaction�grpcF)�typeZhandled)Z mechanism)�hint)r r Zcontinue_from_headers�dictZinvocation_metadatar ZGRPC_SERVERr r � sentry_sdkZstart_transactionZunary_unaryr � Exceptionr Z capture_event)�request�contextr r �exc�eventr# ��handlerr r r �wrapped( s, � � z4ServerInterceptor.intercept_service.<locals>.wrappedc s&