
    lha                         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	 Zd
 Z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        Zy)r   socketzauto.socket.c                  ,    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     p/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/sentry_sdk/integrations/socket.py
setup_oncezSocketIntegration.setup_once   s     	!"r   N)__name__
__module____qualname__
identifieroriginstaticmethodr   r   r   r   r   r      s%    JJ<(F 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)hostportdescriptions      r   _get_span_descriptionr$      se    {{}{{} "4(K / 
 / s   , A >>AAc                  h    t         j                  t         j                  d f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+   r,   r-   )

sentry_sdk
get_clientget_integrationr   
start_spanr   SOCKET_CONNECTIONr$   r   set_data)r+   r,   r-   integrationspanreal_create_connections        r   create_connectionz3_patch_create_connection.<locals>.create_connection2   s     !++-==>OP)'7NKK""##&wqz71:>$++
 	 MM)W-MM)W-MM*N;)	 	 	s   9ACC)r   r7   _GLOBAL_DEFAULT_TIMEOUT)r7   r6   s    @r   r   r   .   s,    #55 ...  1Fr   c                  H    t         j                  dfd	} | t         _        y )Nc           	      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"   )
r.   r/   r0   r   r1   r   
SOCKET_DNSr$   r   r3   )	r!   r"   familytypeprotoflagsr4   r5   real_getaddrinfos	           r   getaddrinfoz'_patch_getaddrinfo.<locals>.getaddrinfoP   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   rA   )rA   r@   s    @r   r   r   L   s    ))L  %Fr   )r   r.   sentry_sdk._typesr   sentry_sdk.constsr   sentry_sdk.integrationsr   r   r   typingr   r	   r
   r   __all__r   r$   r   r   r   r   r   <module>rG      sC      "   /033
 "1<%r   