관리-도구
편집 파일: transaction_profiler.cpython-38.pyc
U �Mg�l � @ sV d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl mZmZ ddl mZ ddlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZ ddlmZ e�r�dd lmZ dd lm Z ddlm!Z! ddlm"Z" dd lm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddl'm(Z( ddlm)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1m2Z2m3Z3 e(de4e.e5d��Z6e(de#e* e#e) e#e6 e"e.e+f d��Z7z*ddl8m9Z9 ddl:m;Z< e<Z;e9dd�Z=W n e>k �r� ej?Z=dZ;Y nX da@dZAdd� ZBdd � ZCd!d"� ZDe5d#�ZEG d$d%� d%�ZFG d&d'� d'e�ZGG d(d)� d)eG�ZHG d*d+� d+eG�ZIdS ),a� This file is originally based on code from https://github.com/nylas/nylas-perftools, which is published under the following license: The MIT License (MIT) Copyright (c) 2014 Nylas Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. � N)�ABC�abstractmethod)�deque)�LRUCache)�DEFAULT_SAMPLING_FREQUENCY� extract_stack)�capture_internal_exception�get_current_thread_meta� is_gevent�is_valid_sample_rate�logger�nanosecond_time�set_in_app_in_frames)� TYPE_CHECKING)�Any)�Callable)�Deque)�Dict)�List)�Optional)�Set)�Type)� TypedDict)�ProcessedStack�ProcessedFrame�ProcessedThreadMetadata�FrameId�StackId�ThreadId�ExtractedSample)�Event�SamplingContext�ProfilerMode�ProcessedSample��elapsed_since_start_nsZ thread_id�stack_id�ProcessedProfile��frames�stacks�samples�thread_metadata)�get_original)� ThreadPool�time�sleep� c C s` | d }|d k rdS | d }|d k r0|dkr0dS | d � d�}|d k r\t�d� |dkr\dS dS )N�profiles_samplerT�profiles_sample_rater �_experimentszy_experiments['profiles_sample_rate'] is deprecated. Please use the non-experimental profiles_sample_rate option directly.F)�getr �warning)�optionsr2 r3 � r8 �V/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/profiler/transaction_profiler.py�has_profiling_enabledx s �r: c C s� t d k rt�d� dS t}t� r(tj}ntj}| �d�d k rF| d }n,| �di ��d�}|d k rjt� d� |pp|}|tjks�|dkr�t|d�a n$|tjkr�t|d�a nt d�|���t�d jt jd �� t �� t �t� dS )Nz%[Profiling] Profiler is already setupF� profiler_moder4 zk_experiments['profiler_mode'] is deprecated. Please use the non-experimental profiler_mode option directly.r0 �� frequencyzUnknown profiler mode: {}z.[Profiling] Setting up profiler in {mode} mode)�modeT)� _schedulerr �debugr r �GeventSchedulerr>