
    \j\                         d dl Z d dlZd dlmZ d dlmZ d dlmZ erd dl mZm	Z	 d dl
mZmZmZmZ dgZ G d de      Zd	d
dddefdZddZddZy)    N)MYPY)OP)Integration)AddressFamily
SocketKind)TupleOptionalUnionListSocketIntegrationc                   ,    e Zd ZdZde Zedd       Zy)r   socketzauto.socket.Nc                  ,    t                t                y)zs
        patches two of the most used functions of socket: create_connection and getaddrinfo(dns resolver)
        N)_patch_create_connection_patch_getaddrinfo     H/root/env/lib/python3.12/site-packages/sentry_sdk/integrations/socket.py
setup_oncezSocketIntegration.setup_once   s    
 	!"r   returnN)__name__
__module____qualname__
identifieroriginstaticmethodr   r   r   r   r   r      s%    JJ<(F r   hostUnion[bytes, str, None]portUnion[bytes, str, int, None]r   c                     	 | j                         } 	 |j                         }| d|}|S # t        t        f$ r Y +w xY w# t        t        f$ r Y /w xY w)N:)decodeUnicodeDecodeErrorAttributeError)r   r    descriptions      r   _get_span_descriptionr(      se    {{}{{} "4(K / 
 / s   , A >>AAc                  x    t         j                  t         j                  d f	 	 	 	 	 	 	 dfd} | t         _        y )Nc                    t        j                         j                  t              }|
 | ||      S t        j                  t
        j                  t        | d   | d         t        j                        5 }|j                  d|        |j                  d|       |j                  d|        | ||      cd d d        S # 1 sw Y   y xY w)Nr      opnamer   addresstimeoutsource_address)r/   r0   r1   )

sentry_sdk
get_clientget_integrationr   
start_spanr   SOCKET_CONNECTIONr(   r   set_data)r/   r0   r1   integrationspanreal_create_connections        r   create_connectionz3_patch_create_connection.<locals>.create_connection0   s    
 !++-==>OP)'7NKK""##&wqz71:>$++
 	 MM)W-MM)W-MM*N;)	 	 	s   9ACC)r/   zTuple[Optional[str], int]r0   zOptional[float]r1   z2Optional[Tuple[Union[bytearray, bytes, str], int]]r   zsocket.socket)r   r;   _GLOBAL_DEFAULT_TIMEOUT)r;   r:   s    @r   r   r   -   sQ    #55 &,%C%COS," M 
	,  1Fr   c                      t         j                  	 	 	 	 ddddddt        dt        dt        dt        d	d
ffd} | t         _        y )Nr   r   r    r!   familytypeprotoflagsr   zvList[Tuple[AddressFamily, SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int], Tuple[int, bytes]]]]c           	      z   t        j                         j                  t              }| | |||||      S t        j                  t
        j                  t        | |      t        j                        5 }|j                  d|        |j                  d|        | |||||      cd d d        S # 1 sw Y   y xY w)Nr,   r   r    )
r2   r3   r4   r   r5   r   
SOCKET_DNSr(   r   r7   )	r   r    r>   r?   r@   rA   r8   r9   real_getaddrinfos	           r   getaddrinfoz'_patch_getaddrinfo.<locals>.getaddrinfoL   s     !++-==>OP#D$eUKK""}}&tT2$++
 	L MM&$'MM&$'#D$eUK	L 	L 	Ls   61B11B:)r   r   r   r   )r   rE   int)rE   rD   s    @r   r   r   I   sw    ))
 L'L,L L 	L
 L L 
BL, %Fr   r   )r   r2   sentry_sdk._typesr   sentry_sdk.constsr   sentry_sdk.integrationsr   r   r   typingr   r	   r
   r   __all__r   strr(   r   r   r   r   r   <module>rM      s[      "   /033

 

#+I"18%r   