OwlCyberSecurity - MANAGER
Edit File: continuous_profiler.cpython-312.pyc
� G��gmW � � � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm Z d dl m Z mZ d dlm Z d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZmZ d d lmZ erad d lmZ d dlmZ d dlmZ d d lm Z d dlm!Z! d dlm"Z" d dlm#Z# d dlm$Z$ d dlm%Z% d dl&m'Z' d dl(m)Z)m*Z* d dlm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 e'de1e.e2d�� Z3 d dl4m5Z5 d dl6m7Z8 e8Z7 e5dd� Z9da<d� Z=d� Z>d� Z?d� Z@d � ZAd!� ZBd"� ZCd#� ZDd$� ZEd%� ZF G d&� d'� ZG G d(� d)� ZH G d*� d+eH� ZI G d,� d-eH� ZJd.ZK G d/� d0� ZL G d1� d2� ZMy# e:$ r ejv Z9dZ7Y �vw xY w)3� N)�deque)�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)�Deque)�Dict)�List)�Optional)�Set)�Type)�Union)� TypedDict)�ContinuousProfilerMode�SDKInfo)�ExtractedSample�FrameId�StackId�ThreadId�ProcessedFrame�ProcessedStack�ProcessedSample�� timestamp� thread_id�stack_id)�get_original)� ThreadPool�time�sleepc �n � t �t j d� yt � rt j }nt j }| j d� �| d }n'| j di � }|j d� xs |}t }|t j k( rt || ||� a n<|t j k( rt || ||� a nt dj |� � �t j dj t j �� � t j t � y ) Nz0[Profiling] Continuous Profiler is already setupF� profiler_mode�_experiments�continuous_profiling_modez$Unknown continuous profiler mode: {}z9[Profiling] Setting up continuous profiler in {mode} mode)�modeT)� _schedulerr �debugr �GeventContinuousSchedulerr0 �ThreadContinuousScheduler�getr � ValueError�format�atexit�register�teardown_continuous_profiler)�options�sdk_info�capture_func�default_profiler_moder- �experiments� frequencys �V/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/profiler/continuous_profiler.py�setup_continuous_profilerrB J s � � �����G�H���{� !:� >� >�� 9� >� >���{�{�?�#�/���0� � �k�k�.�"�5�� �O�O�7�8�Q�<Q� � +�I��1�6�6�6�.��w��,� � � �3�8�8� 8�.��w��,� � � �?�F�F�}�U�V�V� �L�L�C�J�J���� K� �� �O�O�0�1�� c �d � t �y t j � sy t j � y �N)r1 �is_auto_start_enabled�manual_start� rC rA �!try_autostart_continuous_profilerrI } s( � � ����+�+�-�����rC c �8 � t �y t j � S rE )r1 � auto_startrH rC rA �!try_profile_lifecycle_trace_startrL � s � ����� � �"�"rC c �: � t �y t j � y rE )r1 rG rH rC rA �start_profilerrN � s � �������rC c �P � t j dt d�� t � y )NzWThe `start_profile_session` function is deprecated. Please use `start_profile` instead.� �� stacklevel)�warnings�warn�DeprecationWarningrN rH rC rA �start_profile_sessionrV � s! � � �M�M�a���� �rC c �: � t �y t j � y rE )r1 �manual_stoprH rC rA � stop_profilerrY � s � �������rC c �P � t j dt d�� t � y )NzUThe `stop_profile_session` function is deprecated. Please use `stop_profile` instead.rP rQ )rS rT rU rY rH rC rA �stop_profile_sessionr[ � s � � �M�M�_���� �OrC c � � t � d ay rE )rY r1 rH rC rA r: r: � s � ��O� �JrC c �0 � t �y t j S rE )r1 �profiler_idrH rC rA �get_profiler_idr_ � s � �����!�!�!rC c �H � | syt j � t | � k S �NF)�random�float)�sample_rates rA �+determine_profile_session_sampling_decisionre � s � � ���=�=�?�U�;�/�/�/rC c �"