Ë
    S>{i­  ã                   ó–   — d Z ddlZddlmZmZ ddlmZ ddlm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„ Zd„ Zd„ Zd„ Zd„ Zy)zÃ
Instrumentation for Django 3.0

Since this file contains `async def` it is conditionally imported in
`sentry_sdk.integrations.django` (depending on the existence of
`django.core.handlers.asgi`.
é    N)ÚHubÚ
_functools)ÚTYPE_CHECKING)ÚOP)ÚSentryAsgiMiddleware)ÚAny)ÚUnion)ÚCallable)ÚHttpResponsec                 óJ   ‡ ‡‡— ddl mŠ ‰ j                  Šˆˆ ˆfd„}|‰ _        y )Nr   ©ÚDjangoIntegrationc              “   óê   •K  — t         j                  j                  ‰«      € ‰| |||«      ƒ d {  –—† S t        ‰j	                  | ‰«      d¬«      j
                  } ||||«      ƒ d {  –—† S 7 Œ=7 Œ­w)NT©Úunsafe_context_data)r   ÚcurrentÚget_integrationr   Ú__get__Ú
_run_asgi3)ÚselfÚscopeÚreceiveÚsendÚ
middlewarer   ÚclsÚold_apps        €€€úa/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sentry_sdk/integrations/django/asgi.pyÚsentry_patched_asgi_handlerzCpatch_django_asgi_handler_impl.<locals>.sentry_patched_asgi_handler    sr   øè ø€ ä�;‰;×&Ñ&Ð'8Ó9ÐAÙ   u¨g°tÓ<×<Ð<ä)Ø�O‰O˜D #Ó&¸Dô
ç
‰*ð 	ñ    w°Ó5×5Ð5ð =øð
 6ús!   ƒ.A3±A/²8A3Á*A1Á+A3Á1A3)Úsentry_sdk.integrations.djangor   Ú__call__)r   r   r   r   s   ` @@r   Úpatch_django_asgi_handler_implr!      s    ú€ õ Aà�l‰l€Gö6ð /€C…Ló    c                 ó:   ‡‡— | j                   Šˆˆfd„}|| _         y )Nc              “   óB   •K  —  ‰|«        ‰| |«      ƒ d {  –—† S 7 Œ­w©N© )r   ÚrequestÚ_before_get_responseÚold_get_response_asyncs     €€r   Ú!sentry_patched_get_response_asynczCpatch_get_response_async.<locals>.sentry_patched_get_response_async1   s"   øè ø€ á˜WÔ%Ù+¨D°'Ó:×:Ð:Ð:ús   ƒ˜™)Úget_response_async)r   r(   r*   r)   s    ` @r   Úpatch_get_response_asyncr,   -   s   ù€ à ×3Ñ3Ðõ;ð
 ?€CÕr"   c                 óˆ   ‡ ‡‡— dd l }ddlmŠ |j                  dk  r‰ j                  Šˆˆ ˆfd„}|‰ _        y t        ‰ «       y )Nr   r   z3.0.0c              “   óÞ   •‡ K  — t         j                  j                  ‰«      € ‰‰ ||«      ƒ d {  –—† S t        ˆˆˆ fd„d¬«      }  |‰ j                  «      ||«      ƒ d {  –—† S 7 Œ77 Œ­w)Nc                 ó(   •— ‰j                  ‰‰«      S r%   )r   )Ú_scoper   r   r   s    €€€r   ú<lambda>zWpatch_channels_asgi_handler_impl.<locals>.sentry_patched_asgi_handler.<locals>.<lambda>H   s   ø€ ˜wŸ™¨t°SÓ9€ r"   Tr   )r   r   r   r   r   )r   r   r   r   r   r   r   s   `   €€€r   r   zEpatch_channels_asgi_handler_impl.<locals>.sentry_patched_asgi_handlerB   sf   ùè ø€ ä�{‰{×*Ñ*Ð+<Ó=ÐEÙ$ T¨7°DÓ9×9Ð9ä-Ý9ÈtôˆJð 0™ D§J¡JÓ/°¸Ó>×>Ð>ð :øð ?ús!   „-A-±A)²2A-Á$A+Á%A-Á+A-)Úchannelsr   r   Ú__version__r    r!   )r   r2   r   r   r   s   `  @@r   Ú patch_channels_asgi_handler_implr4   9   s:   ú€ ó Ý@à×Ñ˜gÒ%Ø—,‘,ˆö		?ð 3ˆ�ô
 	' sÕ+r"   c                 óF   ‡ ‡— t        j                  ‰«      ˆˆ fd„«       }|S )Nc              Ÿ   óz  •K  — ‰j                  «       5 }|j                  �|j                  j                  «        ‰j                  t        j
                  | j                  j                  ¬«      5   ‰| g|¢­i |¤Žƒ d {  –—† cd d d «       cd d d «       S 7 Œ# 1 sw Y   nxY w	 d d d «       y # 1 sw Y   y xY w­w)N)ÚopÚdescription)Úconfigure_scopeÚprofileÚupdate_active_thread_idÚ
start_spanr   ÚVIEW_RENDERÚresolver_matchÚ	view_name)r'   ÚargsÚkwargsÚsentry_scopeÚcallbackÚhubs       €€r   Úsentry_wrapped_callbackz0wrap_async_view.<locals>.sentry_wrapped_callbackW   sÂ   øè ø€ ð × Ñ Ó"ð 	@ lØ×#Ñ#Ð/Ø×$Ñ$×<Ñ<Ô>à—‘Ü—>‘>¨w×/EÑ/E×/OÑ/Oð  ó ñ @ñ & gÐ?°Ò?¸Ñ?×?÷@ð @÷		@ñ 	@ð @ø÷@ð @úð @÷		@÷ 	@ñ 	@üsM   ƒB;”AB/Á0BÂ BÂBÂ	B/Â
B;ÂBÂB"	ÂB/Â&	B;Â/B8Â4B;)r   Úwraps)rD   rC   rE   s   `` r   Úwrap_async_viewrG   U   s*   ù€ ä×Ñ�hÓô
@ó  ð
@ð #Ð"r"   c                 ó    ‡ —  G ˆ fd„d«      }|S )zh
    Mixin class factory that generates a middleware mixin for handling requests
    in async mode.
    c                   ó2   •— e Zd ZerdZd„ Zd„ Zd„ Zˆ fd„Zy)ú7_asgi_middleware_mixin_factory.<locals>.SentryASGIMixinNc                 ó@   — || _         d | _        | j                  «        y r%   )Úget_responseÚ_acall_methodÚ_async_check)r   rL   s     r   Ú__init__z@_asgi_middleware_mixin_factory.<locals>.SentryASGIMixin.__init__r   s   € à ,ˆDÔØ!%ˆDÔØ×ÑÕr"   c                 ó‚   — t        j                  | j                  «      r t         j                  j                  | _        yy)zé
            If get_response is a coroutine function, turns us into async mode so
            a thread is not consumed during a whole request.
            Taken from django.utils.deprecation::MiddlewareMixin._async_check
            N)ÚasyncioÚiscoroutinefunctionrL   Ú
coroutinesÚ_is_coroutine©r   s    r   rN   zD_asgi_middleware_mixin_factory.<locals>.SentryASGIMixin._async_checkx   s1   € ô ×*Ñ*¨4×+<Ñ+<Ô=Ü%,×%7Ñ%7×%EÑ%E�Õ"ð >r"   c                 ó@   — t        j                  | j                  «      S )z�
            Function that checks if we are in async mode,
            and if we are forwards the handling of requests to __acall__
            )rQ   rR   rL   rU   s    r   Úasync_route_checkzI_asgi_middleware_mixin_factory.<locals>.SentryASGIMixin.async_route_check‚   s   € ô ×.Ñ.¨t×/@Ñ/@ÓAÐAr"   c              Ÿ   óD  •K  — | j                   }|€Gt        | j                  d«      r| j                  j                  x| _         }n| j                  x| _         } ‰|¬«      }|€ ||i |¤Žƒ d {  –—† S |5   ||i |¤Žƒ d {  –—† cd d d «       S 7 Œ 7 Œ# 1 sw Y   y xY w­w)NÚ	__acall__)Ú
old_method)rM   ÚhasattrÚ_innerrY   )r   r@   rA   ÚfÚmiddleware_spanÚ_check_middleware_spans        €r   rY   zA_asgi_middleware_mixin_factory.<locals>.SentryASGIMixin.__acall__Š   s¨   øè ø€ à×"Ñ"ˆAØˆyÜ˜4Ÿ;™;¨Ô4Ø-1¯[©[×-BÑ-BÐB�DÔ&©à-1¯[©[Ð8�DÔ&¨á4ÀÔBˆOàÐ&Ù Ð/¨Ñ/×/Ð/à ñ 0Ù Ð/¨Ñ/×/÷0ñ 0ð 0øð 0ø÷0ð 0üs<   ƒA,B Á/BÁ0B Á6BÂBÂBÂB ÂBÂBÂB )	Ú__name__Ú
__module__Ú__qualname__r   r\   rO   rN   rW   rY   )r_   s   €r   ÚSentryASGIMixinrJ   n   s!   ø„ ÙØˆFò	 ò	Fò	Bõ	0r"   rc   r&   )r_   rc   s   ` r   Ú_asgi_middleware_mixin_factoryrd   g   s   ø€ ÷+0ó +0ðZ Ðr"   )Ú__doc__rQ   Ú
sentry_sdkr   r   Úsentry_sdk._typesr   Úsentry_sdk.constsr   Úsentry_sdk.integrations.asgir   Útypingr   r	   r
   Údjango.http.responser   r!   r,   r4   rG   rd   r&   r"   r   ú<module>rl      sC   ðñó ç &Ý +Ý  å =áÝÝÝå1ò/ò(	?ò,ò8#ó$4r"   