o
    #if                     @   sv   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	 d	Zd
d ZdS )    N)TYPE_CHECKING)Any)Dict)Optional)logger)Envelopec                   @   s   e Zd Zdd Zdd ZdS )SpotlightClientc                 C   s   || _ t | _d| _d S )Nr   )urlurllib3PoolManagerhttptries)selfr	    r   M/var/www/html/corbot_env/lib/python3.10/site-packages/sentry_sdk/spotlight.py__init__   s   

zSpotlightClient.__init__c              
   C   s   | j dkrtd d S t }|| z| jj| j|	 dddid}|
  W d S  tyL } z|  j d7  _ tt| W Y d }~d S d }~w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er   r   r   capture_envelope   s*   

z SpotlightClient.capture_envelopeN)__name__
__module____qualname__r   r$   r   r   r   r   r      s    r   c                 C   s6   |  d}t|tr	 t|S |du rd}t|S d S )N	spotlightTzhttp://localhost:8969/stream)get
isinstancer    r   )optionsr	   r   r   r   setup_spotlight.   s   

r,   )r   r
   sentry_sdk._typesr   typingr   r   r   sentry_sdk.utilsr   sentry_sdk.enveloper   r   r,   r   r   r   r   <module>   s    