bg rddlZddlZddlmZmZddlZddlmZddlm Z e rddl m Z Gdde Z dS)N)ThreadLock)logger) TYPE_CHECKING)Optionalc^eZdZdZdZddZdZdZdZdZ d Z e d Z d Z d Zd S)Monitorz Performs health checks in a separate thread once every interval seconds and updates the internal state. Other parts of the SDK only read this state and act accordingly. zsentry.monitor c||_||_d|_d|_d|_t |_d|_d|_dS)NT) transportinterval_healthy_downsample_factor_threadr _thread_lock_thread_for_pid_running)selfr rs I/opt/cloudlinux/venv/lib64/python3.11/site-packages/sentry_sdk/monitor.py__init__zMonitor.__init__sE"   "#  FF# cjtjkr jdSj5jtjkrj ddddSfd}t j|}d|_||_tj_dddn #1swxYwYdS)Ncjr=tjjjrj;dSdSN)rtimesleeprrunrsrrz(Monitor._ensure_running.._thread,sVm#Jt}---}# m#####r)nametargetT) rosgetpidrrrr daemonstart)rrthreads` r_ensure_runningzMonitor._ensure_running#s&  29;; . .4<3K4   / /#ry{{22t|7O / / / / / / / / # # # # #7;;;F FM LLNNN!DL#%9;;D  / / / / / / / / / / / / / / /"ts%C ACCCcV||dSr) check_healthset_downsample_factorrs rrz Monitor.run;s,  ""$$$$$rc|jr(|jdkrtjdd|_dS|xjdzc_tjd|jdS)Nr z=[Monitor] health check positive, reverting to normal samplingzA[Monitor] health check negative, downsampling with a factor of %d)rrrdebugrs rr*zMonitor.set_downsample_factor@s| = &** S'(D # # #  # #q ( # # LS'     rcB|j|_dS)z Perform the actual health checks, currently only checks if the transport is rate-limited. TODO: augment in the future with more checks. N)r is_healthyrrs rr)zMonitor.check_healthOs1133 rc8||jSr)r'rrs rr/zMonitor.is_healthyXs }rc8||jSr)r'rrs rdownsample_factorzMonitor.downsample_factor]s &&rcd|_dS)NF)rrs rkillz Monitor.killcs  rc.|dSr)r4rs r__del__zMonitor.__del__gs rN)r )__name__ __module__ __qualname____doc__r rr'rr*r)r/propertyr2r4r6rrr r s D    0%%%   444 ''X' rr )r"r threadingrr sentry_sdksentry_sdk.utilsrsentry_sdk._typesrtypingrobjectr r<rrrCs """"""""######++++++ \\\\\f\\\\\r