Ë
    S>{i=  ã                   ón   — d dl Z d dlZd dlmZmZ d dlZd dlmZ d dlm	Z	 e	rd dl
mZ dZ G d„ de«      Zy)	é    N)ÚThreadÚLock)Úlogger)ÚTYPE_CHECKING)ÚOptionalé
   c                   óV   — e Zd ZdZdZdd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
ed	„ «       Zd
„ Zd„ Zy)Ú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.
    zsentry.monitorc                 ó„   — || _         || _        d| _        d| _        d | _        t        «       | _        d | _        d| _        y )NTr   )	Ú	transportÚintervalÚ_healthyÚ_downsample_factorÚ_threadr   Ú_thread_lockÚ_thread_for_pidÚ_running)Úselfr   r   s      úP/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sentry_sdk/monitor.pyÚ__init__zMonitor.__init__   s?   € à"ˆŒØ ˆŒàˆŒØ"#ˆÔàˆŒÜ ›FˆÔØ#ˆÔØˆ�ó    c                 ó¸  ‡ — ‰ j                   t        j                  «       k(  r‰ j                  �y ‰ j                  5  ‰ j                   t        j                  «       k(  r‰ j                  �
	 d d d «       y ˆ fd„}t        ‰ j                  |¬«      }d|_        |j                  «        |‰ _        t        j                  «       ‰ _         d d d «       y # 1 sw Y   y xY w)Nc                  ó°   •— ‰ j                   rIt        j                  ‰ j                  «       ‰ j                   r‰ j	                  «        ‰ j                   rŒHy y ©N)r   ÚtimeÚsleepr   Úrun©r   s   €r   r   z(Monitor._ensure_running.<locals>._thread/   s3   ø€ à—m’mÜ—J‘J˜tŸ}™}Ô-Ø—}’}ØŸ™œ
ð —m•mr   )ÚnameÚtargetT)	r   ÚosÚgetpidr   r   r   r   ÚdaemonÚstart)r   r   Úthreads   `  r   Ú_ensure_runningzMonitor._ensure_running&   s¬   ø€ à×Ñ¤2§9¡9£;Ò.°4·<±<Ð3KØà×Ññ 	/Ø×#Ñ#¤r§y¡y£{Ò2°t·|±|Ð7OØ÷	/ð 	/ô#ô  §¡°7Ô;ˆFØ ˆFŒMØ�L‰LŒNØ!ˆDŒLÜ#%§9¡9£;ˆDÔ ÷	/ð" ÷#	/ð" ús   ¼/CÁ4ACÃCc                 óD   — | j                  «        | j                  «        y r   )Úcheck_healthÚset_downsample_factorr   s    r   r   zMonitor.run>   s   € à×ÑÔØ×"Ñ"Õ$r   c                 ó  — | j                   r,| j                  dkD  rt        j                  d«       d| _        y | j                  t
        k  r| xj                  dz  c_        t        j                  d| j                  «       y )Nr   z=[Monitor] health check positive, reverting to normal samplingé   zA[Monitor] health check negative, downsampling with a factor of %d)r   r   r   ÚdebugÚdownsample_factorÚMAX_DOWNSAMPLE_FACTORr   s    r   r)   zMonitor.set_downsample_factorC   sh   € à�=Š=Ø×&Ñ&¨Ò*Ü—‘ØSôð '(ˆDÕ#à×%Ñ%Ô(=Ò=Ø×'Ò'¨1Ñ,Õ'Ü�L‰LØSØ×'Ñ'õr   c                 óB   — | j                   j                  «       | _        y)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_healthyr   r   s    r   r(   zMonitor.check_healthS   s   € ð Ÿ™×1Ñ1Ó3ˆ�r   c                 ó:   — | j                  «        | j                  S r   )r&   r   r   s    r   r0   zMonitor.is_healthy\   s   € à×ÑÔØ�}‰}Ðr   c                 ó:   — | j                  «        | j                  S r   )r&   r   r   s    r   r-   zMonitor.downsample_factora   s   € ð 	×ÑÔØ×&Ñ&Ð&r   c                 ó   — d| _         y )NF)r   r   s    r   ÚkillzMonitor.killg   s	   € àˆ�r   c                 ó$   — | j                  «        y r   )r4   r   s    r   Ú__del__zMonitor.__del__k   s   € à�	‰	�r   N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r&   r   r)   r(   r0   Úpropertyr-   r4   r6   © r   r   r
   r
      sJ   „ ñð €Dóòò0%ò
ò 4òð
 ñ'ó ð'ò
ór   r
   )r!   r   Ú	threadingr   r   Ú
sentry_sdkÚsentry_sdk.utilsr   Úsentry_sdk._typesr   Útypingr   r.   Úobjectr
   r<   r   r   ú<module>rC      s3   ðÛ 	Û ß "ã Ý #Ý +áÝð Ð ô]ˆfõ ]r   