
    Yf                     z    d dl Z d dlZd dlmZ erd dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ  G d d	      Zd
 Zy)    N)TYPE_CHECKING)Any)Dict)Optional)logger)Envelopec                       e Zd Zd Zd Zy)SpotlightClientc                 R    || _         t        j                         | _        d| _        y )Nr   )urlurllib3PoolManagerhttptries)selfr   s     T/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/sentry_sdk/spotlight.py__init__zSpotlightClient.__init__   s     '')	
    c                    | j                   dkD  rt        j                  d       y t        j                         }|j                  |       	 | j                  j                  | j                  |j                         dddi      }|j                          y # t        $ r=}| xj                   dz  c_         t        j                  t        |             Y d }~y d }~ww xY w)N   z@Too many errors sending to Spotlight, stop sending events there.POSTzContent-Typezapplication/x-sentry-envelope)r   bodymethodheaders   )r   r   warningioBytesIOserialize_intor   requestr   getvalueclose	Exceptionstr)r   enveloper   reqes        r   capture_envelopez SpotlightClient.capture_envelope   s    ::>NNR zz|%	#))##HH]]_"$C	 $ C IIK 	#JJ!OJNN3q6""	#s   A	B 	C3CCN)__name__
__module____qualname__r   r(    r   r   r
   r
      s    #r   r
   c                     | j                  d      }t        |t              r	 t        |      S |du rd}t        |      S y )N	spotlightTzhttp://localhost:8969/stream)get
isinstancer$   r
   )optionsr   s     r   setup_spotlightr2   .   sL     ++k
"C#s 3 
, 3 r   )r   r   sentry_sdk._typesr   typingr   r   r   sentry_sdk.utilsr   sentry_sdk.enveloper   r
   r2   r,   r   r   <module>r7      s/    	  + # (# #> r   