
    fi                     .   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 n# e$ r  ed          w xY w	 d dlZn# e$ r  ed          w xY wdZ G d de          Zd Zd ZdS )    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dS )FastApiIntegrationfastapic                  "    t                       d S N)patch_get_request_handler     o/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/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   "   s2        J$ $ \$ $ $r   r   c                 T   d}|dk    r.|j                             d          }|rt          |          pd}n7|dk    r1|j                             d          }|rt          |dd           }||}|st          }t
          j        }nt          |         }|                     ||           d S )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0 	=,X66<"D	e	#	#!!'** 	5&$//D 5("(!"34	tF33333r   c                  V    t           j        j        fd} | t           j        _        d S )Nc                      |                     d          }|rH|j        At          j        |j                  s(|j        t	                    fd            }||_         | i |fd}|S )N	dependantc                      t          j                    }|j        |j                                         t          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   sr     !+ < > > ,8!-BBDDD)=??'3 (@@BBBx0000r   c                    K   t          j                                        t                    }| | i | d {V S | d         }t	          t          j                    |j        |           t          j                    }t          |          }|	                                 d {V fd}t          j
        |_        |                     |||                      | i | d {V S )Nr   c                     fd}|S )Nc                     |                      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   st     $)99Y#;#;L @$,,1H1J1J,6: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   s7     $/11AABTUUK"$Wd5f5555555551gG,,..0Mw   &9;;L1'::I"7799999999D' ' ' ' '$ "4!>L,,--g{CC   !$1&111111111r   )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   s    JJ{++		**/	?? + !~H8__
1 
1 
1 
1 _
1 *IN))4:6::&	2 &	2 &	2 &	2 &	2P r   )r   routingget_request_handler)r[   rZ   s    @r   r   r   D   s@    %oAC C C C CJ +FGO'''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 0 0 0 0 0 4 4 4 4 4 4 B B B B B B B B 6 6 6 6 6 6             (**********''''''5          5 5 5
,3
4
4453NNNN 3 3 3
,1
2
223 6 $ $ $ $ $- $ $ $4 4 42IF IF IF IF IFs   A A"&A+ +A<