관리-도구
편집 파일: tracing.cpython-37.pyc
B T a�d � @ sz d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlm Z d dl Z d dlmZm Z mZ d dlmZ d dlmZ er�d dlmZ nd dlmZ er�d dlZd dlmZ d d lmZ d d lmZ d dlmZ d dlmZ d d lmZ d dlmZ e �d�ZG dd� de�Z G dd� de!�Z"G dd� de!�Z#G dd� de#�Z$dd� Z%dd� Z&dd� Z'ej(dd� �Z)d d!� Z*dS )"� N)�datetime� timedelta)�Real)�capture_internal_exceptions�logger� to_string)�PY2)�MYPY)�Mapping)� Generator)�Optional)�Any)�Dict)�List)�Tuple)�SamplingContextz5^[ ]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ ]*$c @ s. e Zd Zddd�Zdd� Zdd� Zdd � Zd S )�EnvironHeaders�HTTP_c C s || _ || _d S )N)�environ�prefix)�selfr r � r �C/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/tracing.py�__init__0 s zEnvironHeaders.__init__c C s | j | j|�dd��� S )N�-�_)r r �replace�upper)r �keyr r r �__getitem__9 s zEnvironHeaders.__getitem__c C s t dd� t| �D ��S )Nc s s | ] }d V qdS )� Nr )�.0r r r r � <genexpr>? s z)EnvironHeaders.__len__.<locals>.<genexpr>)�sum�iter)r r r r �__len__= s zEnvironHeaders.__len__c c sR xL| j D ]B}t|t�sq|�dd��� }|�| j�s6q|t| j�d � V qW d S )Nr r )r � isinstance�strr r � startswithr �len)r �kr r r �__iter__A s zEnvironHeaders.__iter__N)r )�__name__� __module__�__qualname__r r r% r+ r r r r r / s r c @ s$ e Zd ZdZdZdd� Zdd� ZdS )� _SpanRecorderz5Limits the number of spans recorded in a transaction.)�maxlen�spansc C s |d | _ g | _d S )Nr )r0 r1 )r r0 r r r r S s z_SpanRecorder.__init__c C s( t | j�| jkrd |_n| j�|� d S )N)r) r1 r0 �_span_recorder�append)r �spanr r r �add] s z_SpanRecorder.addN)r, r- r. �__doc__� __slots__r r5 r r r r r/ N s r/ c @ s� e Zd ZdZdd� Zd.dd�Zdd � Zd d� Zdd � Zdd� Z dd� Z dd� Zedd� �Z edd� �Zdd� Zedd� �Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd/d(d)�Zd*d+� Zd,d-� ZdS )0�Span)�trace_id�span_id�parent_span_id�same_process_as_parent�sampled�op�description�start_timestamp�_start_timestamp_monotonic�status� timestamp�_tags�_datar2 �hub�_context_manager_state�_containing_transactionc K s d|krt �t�S t �| �S )z_ Backwards-compatible implementation of Span and Transaction creation. �transaction)�object�__new__�Transaction)�cls�kwargsr r r rK | s zSpan.__new__NTc C s� |pt �� j| _|p$t �� jdd � | _|| _|| _|| _|| _|| _ | | _ || _i | _i | _ t�� | _yt�� | _W n tk r� Y nX d | _d | _d | _d S )N� )�uuidZuuid4�hexr9 r: r; r<