
    lh                        d dl Z d dlmZ d dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZmZ d dlmZ d dlmZ erd d	lmZmZmZ d d
lmZ 	 d dlmZmZ 	 d dlZdZ G d de      Zd Zd Zy# e$ r	  ed      w xY w# e$ r	  ed      w xY w)    N)deepcopy)wraps)DidNotEnable)should_send_default_pii)SOURCE_FOR_STYLETransactionSource)transaction_from_function)TYPE_CHECKING)AnyCallableDict)Event)StarletteIntegrationStarletteRequestExtractorzStarlette is not installedzFastAPI is not installedzgeneric FastAPI requestc                        e Zd ZdZed        Zy)FastApiIntegrationfastapic                      t                y N)patch_get_request_handler     q/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/sentry_sdk/integrations/fastapi.py
setup_oncezFastApiIntegration.setup_once%   s
     	"#r   N)__name__
__module____qualname__
identifierstaticmethodr   r   r   r   r   r   "   s    J$ $r   r   c                 <   d}|dk(  r-|j                   j                  d      }|rCt        |      xs d}n3|dk(  r.|j                   j                  d      }|rt        |dd       }||}|st        }t
        j                  }n	t        |   }| j                  ||       y )N endpointurlroutepath)source)	scopegetr	   getattr_DEFAULT_TRANSACTION_NAMEr   ROUTEr   set_transaction_name)r'   transaction_stylerequestnamer"   r$   r%   r&   s           r    _set_transaction_name_and_sourcer0   +   s    DJ&==$$Z0,X6<"D	e	#!!'*5&$/D("((!"34	tF3r   c                  n    t         j                  j                  fd} | t         j                  _        y )Nc                      |j                  d      }|rQ|j                  Et        j                  |j                        s&|j                  t	              fd       }||_         | i |fd}|S )N	dependantc                      t        j                         }|j                  |j                  j                          t        j                         }|j
                  |j
                  j                           | i |S r   )
sentry_sdkget_current_scopetransactionupdate_active_threadget_isolation_scopeprofileupdate_active_thread_id)argskwargscurrent_scopesentry_scopeold_calls       r   _sentry_callzTpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_callR   sm     !+ < < > ,,8!--BBD)==?''3 ((@@B000r   c                    K   t        j                         j                  t              }| | i | d {   S | d   }t	        t        j
                         |j                  |       t        j                         }t        |      }|j                          d {   fd}t        j                  |_        |j                   |||              | i | d {   S 7 7 H7 w)Nr   c                     fd}|S )Nc                     | j                  di       }r"dv rt               rd   |d<   dv rd   |d<   t        |      | d<   | S )Nr.   cookiesdata)r(   r   r   )eventhintrequest_infoinfos      r   event_processorzpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processor.<locals>.event_processort   s]     $)99Y#;L$,1H1J6:9oL3!T>37<L0'/'=E)$ Lr   r   )reqintegrationrK   rJ   s      r   _make_request_event_processorzzpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_app.<locals>._make_request_event_processorr   s    ! '&r   )r5   
get_clientget_integrationr   r0   r6   r-   r9   r   extract_request_infor   _nameadd_event_processor)	r<   r=   rM   r.   r?   	extractorrN   rJ   old_apps	          @r   _sentry_appzSpatch_get_request_handler.<locals>._sentry_get_request_handler.<locals>._sentry_appc   s     $//1AABTUK"$d5f5551gG,,,.0M0Mw &99;L1':I"7799D'$ "4!>!>L,,-g{C !$1&111E 6 :2 2s5   5C+C%A$C+C'AC+ C)!C+'C+)C+)r(   callasyncioiscoroutinefunctionr   )r<   r=   r3   rA   rV   rU   r@   old_get_request_handlers        @@r   _sentry_get_request_handlerz>patch_get_request_handler.<locals>._sentry_get_request_handlerH   su    JJ{+	*//	? ~~H8_
1 
1 *IN)4:6:&	2P r   )r   routingget_request_handler)r[   rZ   s    @r   r   r   D   s)    %ooAACJ +FGOO'r   )rX   copyr   	functoolsr   r5   sentry_sdk.integrationsr   sentry_sdk.scoper   sentry_sdk.tracingr   r   sentry_sdk.utilsr	   typingr
   r   r   r   sentry_sdk._typesr   !sentry_sdk.integrations.starletter   r   r   ImportErrorr*   r   r0   r   r   r   r   <module>rh      s        0 4 B 6  **'53
 6 $- $42IF]  5
3
445
  3
1
223s   A) A: )A7:B