관리-도구
편집 파일: hub.cpython-38.pyc
U �MgJd � @ s d dl Z d dlmZ d dlmZmZmZmZ d dlm Z d dl mZ d dlm Z d dlmZ d dlmZmZmZ d d lmZmZ d d lmZ e�r�d dlmZ d dlmZ d d lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm Z d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dl%m&Z& d dlm'Z' d dlm(Z( d dl)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dlm3Z3 e#d�Z4ndd� Z G d d!� d!e5�Z6ed"d#� �Z7ed$�Z8G d%d&� d&e9�Z:G d'd(� d(e e:��Z;e7� � e;� Z<W 5 Q R X e8�=e<� d d)lm>Z> dS )*� N)�contextmanager)� get_client�get_global_scope�get_isolation_scope�get_current_scope)�with_metaclass)�INSTRUMENTER)� _ScopeManager)�Client)�NoOpSpan�Span�Transaction)�logger� ContextVar)� TYPE_CHECKING)�Any)�Callable)�ContextManager)�Dict)� Generator)�List)�Optional)�overload)�Tuple)�Type)�TypeVar)�Union)�Unpack)�Scope)� BaseClient)�Integration)�Event�Hint� Breadcrumb�BreadcrumbHint�ExcInfo�LogLevelStr�SamplingContext)�TransactionKwargs�Tc C s | S �N� )�xr+ r+ �</opt/hc_python/lib/python3.8/site-packages/sentry_sdk/hub.pyr = s r c s$ e Zd ZdZdZ� fdd�Z� ZS )�SentryHubDeprecationWarningzR A custom deprecation warning to inform users that the Hub is deprecated. z�`sentry_sdk.Hub` is deprecated and will be removed in a future major release. Please consult our 1.x to 2.x migration guide for details on how to migrate `Hub` usage to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.xc s t � �| j� d S r* )�super�__init__�_MESSAGE)�self�_�� __class__r+ r- r0 N s z$SentryHubDeprecationWarning.__init__)�__name__� __module__�__qualname__�__doc__r1 r0 � __classcell__r+ r+ r4 r- r. B s �r. c c s, t �� � t jdtd� dV W 5 Q R X dS )z>Utility function to suppress deprecation warnings for the Hub.�ignore)�categoryN)�warnings�catch_warnings�filterwarningsr. r+ r+ r+ r- �!_suppress_hub_deprecation_warningS s r@ Zsentry_current_hubc @ s$ e Zd Zedd� �Zedd� �ZdS )�HubMetac C sJ t jt� dd� t�d�}|dkrFt� � tt�}W 5 Q R X t�|� |S )z(Returns the current instance of the hub.� �� stacklevelN) r= �warnr. �_local�getr@ �Hub� GLOBAL_HUB�set)�cls�rvr+ r+ r- �current` s zHubMeta.currentc C s t jt� dd� tS )z%Returns the main instance of the hub.rB rC )r= rE r. rI )rK r+ r+ r- �mainm s zHubMeta.mainN)r6 r7 r8 �propertyrM rN r+ r+ r+ r- rA _ s rA c @ sh e Zd ZdZdZdZer dZdZdAdd�Z dd� Z dd� Zd d � Zdd� Z ed d� �Zedd� �Zdd� Zdd� ZdBdd�ZdCdd�ZdDdd�ZdEdd�Zejfdd�Zdejdfdd �ZdFd!d"�ZedGd#d$��Zed%d$� �ZdHd'd$�Zd(d)� ZedId*d+��Zed,d+� �ZdJd-d+�ZdKd/d0�Z d1d2� Z!d3d4� Z"d5d6� Z#dLd7d8�Z$d9d:� Z%d;d<� Z&dMd=d>�Z'dNd?d@�Z(dS )OrH a� .. deprecated:: 2.0.0 The Hub is deprecated. Its functionality will be merged into :py:class:`sentry_sdk.scope.Scope`. The hub wraps the concurrency management of the SDK. Each thread has its own hub but the hub might transfer with the flow of execution if context vars are available. If the hub is used with a with statement it's temporarily activated. Nc C s� t jt� dd� d }t|t�rBt� }|d krRt� �� }t� �� }n|}t � � |� |d krft� }t� }|d krtt� }||fg| _d | _g | _ g | _g | _|| _|| _d S )NrB rC )r= rE r. � isinstancerH r r �forkr r � set_client�_stack�_last_event_id� _old_hubs�_old_current_scopes�_old_isolation_scopes�_current_scope�_scope)r2 Z client_or_hub�scope� current_scope�clientr+ r+ r- r0 � s* zHub.__init__c C s\ | j �tj� t�| � t� }| j�|� tj �| j � t � }| j�|� tj�| j � | S r* )rU �appendrH rM rF rJ r rV rZ rX r rW �_isolation_scoperY )r2 r[ �isolation_scoper+ r+ r- � __enter__� s z Hub.__enter__c C sD | j �� }t�|� | j�� }tj�|� | j�� }tj�|� d S r* ) rU �poprF rJ rV rZ rX rW r^ )r2 �exc_type� exc_value�tb�oldZold_current_scopeZold_isolation_scoper+ r+ r- �__exit__� s zHub.__exit__c C s"