관리-도구
편집 파일: continuous_profiler.cpython-38.pyc
U �MgC � @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlm Z d dl mZ d dlm Z d dlmZmZ d dlmZmZmZmZmZ d dlmZ e�rDd d lmZ d d lmZ d dlmZ d dlmZ d d lmZ d dlmZ d dlmZ d dl m!Z! d dl"m#Z#m$Z$ d dlm%Z%m&Z&m'Z'm(Z(m)Z)m*Z* e!de+e(e,d��Z-z*d dl.m/Z/ d dl0m1Z2 e2Z1e/dd�Z3W n e4k �r� ej5Z3dZ1Y nX da6dd� Z7dd� Z8dd� Z9dd � Z:d!d"� Z;d#d$� Z<G d%d&� d&�Z=G d'd(� d(e=�Z>G d)d*� d*e=�Z?d+Z@G d,d-� d-�ZAG d.d/� d/�ZBdS )0� N)�datetime�timezone)�VERSION)�Envelope)�LRUCache)�DEFAULT_SAMPLING_FREQUENCY� extract_stack)�capture_internal_exception� is_gevent�logger�now�set_in_app_in_frames)� TYPE_CHECKING)�Any)�Callable)�Dict)�List)�Optional)�Type)�Union)� TypedDict)�ContinuousProfilerMode�SDKInfo)�ExtractedSample�FrameId�StackId�ThreadId�ProcessedFrame�ProcessedStack�ProcessedSample�� timestampZ thread_id�stack_id)�get_original)� ThreadPool�time�sleepc C s� t d k rt�d� dS t� r$tj}ntj}| �di �}|�d�pB|}t}|tjkrbt|| ||�a n(|tjkr|t|| ||�a nt d� |���t�dj t jd�� t�t � dS ) Nz0[Profiling] Continuous Profiler is already setupF�_experimentsZcontinuous_profiling_modez$Unknown continuous profiler mode: {}z9[Profiling] Setting up continuous profiler in {mode} mode)�modeT)� _schedulerr �debugr �GeventContinuousSchedulerr( �ThreadContinuousScheduler�getr � ValueError�format�atexit�register�teardown_continuous_profiler)�options�sdk_info�capture_funcZdefault_profiler_mode�experimentsZ profiler_mode� frequency� r8 �U/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/profiler/continuous_profiler.py�setup_continuous_profilerE s@ � � ��� r: c C s$ t d krd S t �� sd S t �� d S �N)r) �should_autostart�ensure_runningr8 r8 r8 r9 �!try_autostart_continuous_profilert s r>