관리-도구
편집 파일: sanic.cpython-37.pyc
B T a�! � @ s� d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl m Z mZmZm Z d dlmZmZ d dlmZmZ d dlmZ d d lmZ er�d d lmZ d dlmZ d dlmZ d d lmZ d dlmZ d dlmZ d dlm Z m!Z! d dlm"Z"m#Z#m$Z$ y8d dl%m&Z&m'Z( d dl)m*Z* d dl+m,Z, d dl-m.Z. W n e/k �rN ed��Y nX G dd� de�Z0dd� Z1dd� Z2G dd� de�Z3dS )� N)�isawaitable)�urlparse�reraise)�Hub)�capture_internal_exceptions�event_from_exception�HAS_REAL_CONTEXTVARS�CONTEXTVARS_ERROR_MESSAGE)�Integration�DidNotEnable)�RequestExtractor�_filter_headers)� ignore_logger)�MYPY)�Any)�Callable)�Optional)�Union)�Tuple)�Dict)�Request�RequestParameters)�Event�EventProcessor�Hint)�Sanic�__version__)�SanicException)�Router)�ErrorHandlerzSanic not installedc @ s e Zd ZdZedd� �ZdS )�SanicIntegration�sanicc s� yt ttt�d����W n& ttfk r> td�t���Y nX �dk rPtd��t s`tdt ��t�d�rrtd� t j��fdd �} | t _tj���fd d�}|t_tj� � fdd �}|t_d S )N�.zUnparsable Sanic version: {})r � zSanic 0.8 or newer required.zUThe sanic integration for Sentry requires Python 3.7+ or the aiocontextvars package.z0.8.�rootc � s� t j}|�t�d kr&� | |f|�|�S t�|�}t |��T}|�� �}|�� |�t |�� W d Q R X � | |f|�|�}t |�r�|I d H }|S Q R X d S )N)r �current�get_integrationr �weakref�ref�configure_scopeZclear_breadcrumbsZadd_event_processor�_make_request_processorr )�self�request�args�kwargs�hub�weak_request�scope�response)�old_handle_request� �N/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/integrations/sanic.py�sentry_handle_requestL s z:SanicIntegration.setup_once.<locals>.sentry_handle_requestc s� � | f|�� }t j}|�t�d k r�t� �l |�� �X}�dkrz| jjj}|d j}|� d| �rr|t |�d d � }||_n|d j|_W d Q R X W d Q R X |S )N)� � r z%s.� ) r r% r&