Ë
    S>{i>   ã                   óV  — d dl Z d dlmZ d dlmZ d dlm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mZ d d
lmZmZmZmZmZ d dlmZ d dlmZ d dlmZ dZdZ er7d dlmZ d dl!m"Z" d dl!m#Z# d dl!m$Z$ d dl!m%Z% d dlm&Z&m'Z'm(Z(  e#de$de"f   ¬«      Z)d„ Z* G d„ de«      Z+d„ Z,d„ Z-y)é    N)Údeepcopy)Ú	timedelta)Úenviron)Úcontinue_trace)ÚOP)ÚHubÚ_should_send_default_pii)ÚTRANSACTION_SOURCE_COMPONENT)Údatetime_utcnowÚreraise)ÚAnnotatedValueÚcapture_internal_exceptionsÚevent_from_exceptionÚloggerÚTimeoutThread)ÚIntegration)Ú_filter_headers)ÚTYPE_CHECKINGg      ø?g     @�@)Údatetime)ÚAny)ÚTypeVar)ÚCallable)ÚOptional)ÚEventProcessorÚEventÚHintÚF.)Úboundc                 ó   ‡ — ˆ fd„}|S )Nc           
      ó^  •— t         j                  }|j                  t        «      }|€ ‰| |g|¢­i |¤ŽS |j                  }t        j                  d«      }|s"t        j                  d«        ‰| |g|¢­i |¤ŽS t        |«      }t        «       }|j                  «       5 }	t        «       5  |	j                  «        |	j                  t        |||«      «       |	j!                  dt        j                  d«      «       d }
|j"                  r.|t$        kD  r%|t$        z
  }t'        ||«      }
|
j)                  «        d d d «       i }t+        |d«      r|j,                  }t/        |t0        j2                  t        j                  dd«      t4        ¬«      }t        j                  d«      t        j                  d	«      t        j                  d
«      t        j                  d«      t        j                  d«      dœ|dœ}|j7                  ||¬«      5  	  ‰| |g|¢­i |¤Ž
r|
j9                  «        |j;                  «        cd d d «       cd d d «       S # 1 sw Y   �ŒxY w# t<        $ rP t?        j@                  «       }tC        ||jD                  dddœ¬«      \  }}|jG                  ||¬«       tI        |Ž  Y nw xY w	 
r|
j9                  «        |j;                  «        n'# 
r|
j9                  «        |j;                  «        w xY w	 d d d «       n# 1 sw Y   nxY wd d d «       y # 1 sw Y   y xY w)NÚFUNCTION_TIMEOUT_SECzOThe configured timeout could not be fetched from Cloud Functions configuration.Ú
gcp_regionÚFUNCTION_REGIONÚheadersÚFUNCTION_NAMEÚ )ÚopÚnameÚsourceÚENTRY_POINTÚFUNCTION_IDENTITYÚGCP_PROJECT)Úfunction_nameÚfunction_entry_pointÚfunction_identityÚfunction_regionÚfunction_project)Úgcp_envÚ	gcp_event)Úcustom_sampling_contextÚgcpF)ÚtypeÚhandled)Úclient_optionsÚ	mechanism)Úhint)%r   ÚcurrentÚget_integrationÚGcpIntegrationÚclientr   Úgetr   ÚdebugÚintr   Ú
push_scoper   Úclear_breadcrumbsÚadd_event_processorÚ_make_request_event_processorÚset_tagÚtimeout_warningÚTIMEOUT_WARNING_BUFFERr   ÚstartÚhasattrr$   r   r   ÚFUNCTION_GCPr
   Ústart_transactionÚstopÚflushÚ	ExceptionÚsysÚexc_infor   ÚoptionsÚcapture_eventr   )Úfunctionhandlerr3   ÚargsÚkwargsÚhubÚintegrationr>   Úconfigured_timeÚinitial_timeÚscopeÚtimeout_threadÚwaiting_timer$   ÚtransactionÚsampling_contextrQ   Úsentry_eventr:   Úfuncs                     €úY/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sentry_sdk/integrations/gcp.pyÚsentry_funcz_wrap_func.<locals>.sentry_func)   sî  ø€ ô �k‰kˆØ×)Ñ)¬.Ó9ˆØÐÙ˜¨ÐD°TÒD¸VÑDÐDð —‘ˆä!Ÿ+™+Ð&<Ó=ˆÙÜ�L‰LØaôñ ˜¨ÐD°TÒD¸VÑDÐDä˜oÓ.ˆä&Ó(ˆà�^‰^Óð ;	  Ü,Ó.ñ +Ø×'Ñ'Ô)Ø×)Ñ)Ü1Ø! ?°Lóôð
 —‘˜l¬G¯K©KÐ8IÓ,JÔKØ!%�à×/Ò/Ø'Ô*@Ò@à#2Ô5KÑ#K�Lä%2°<ÀÓ%Q�Nð #×(Ñ(Ô*÷%+ð( ˆGÜ�y )Ô,Ø#×+Ñ+�ä(ØÜ—?‘?Ü—[‘[ °"Ó5Ü3ô	ˆKô &-§[¡[°Ó%AÜ,3¯K©K¸Ó,FÜ)0¯©Ð5HÓ)IÜ'.§{¡{Ð3DÓ'EÜ(/¯©°MÓ(Bñð 'ñ	 Ðð ×&Ñ&ØÐ5Eð 'ó ñ  ð Ù °ÐL¸TÒLÀVÑLñ &Ø&×+Ñ+Ô-à—I‘I”K÷% ð  ÷S;	 ñ ;	 ÷+ñ +ûôZ !ò 'Ü"Ÿ|™|›~�HÜ)=Ø Ø'-§~¡~Ø+0¸UÑ"Cô*Ñ&�L $ð
 ×%Ñ% l¸Ð%Ô>Ü˜XÓ&ð'úð 'á%Ø&×+Ñ+Ô-à—I‘I•Køñ &Ø&×+Ñ+Ô-à—I‘I•Kú�K÷% ÷  ñ  ú÷S;	 ÷ ;	 ñ ;	 ús{   Â L#Â+BIÄ9CL#ÈLÈIÈ"LÈ=	L#ÉI	ÉL#ÉAJ6Ê3KÊ5J6Ê6KÊ:#LË$LÌLÌ	L#ÌL	ÌL#Ì#L,© )ra   rc   s   ` rb   Ú
_wrap_funcre   '   s   ø€ ôQ ðf Ðó    c                   ó(   — e Zd ZdZdd„Zed„ «       Zy)r=   r5   c                 ó   — || _         y )N)rG   )ÚselfrG   s     rb   Ú__init__zGcpIntegration.__init__‚   s
   € à.ˆÕrf   c                  óÄ   — dd l } t        | d«      st        j                  d«       y | j                  }t        |j                  j                  «      |j                  _        y )Nr   Ú	worker_v1zFGcpIntegration currently supports only Python 3.7 runtime environment.)Ú__main__rJ   r   Úwarningrl   re   ÚFunctionHandlerÚinvoke_user_function)Úgcp_functionsÚworker1s     rb   Ú
setup_oncezGcpIntegration.setup_once†   sR   € ó 	)ä�} kÔ2Ü�N‰NØXôð à×)Ñ)ˆä7AØ×#Ñ#×8Ñ8ó8
ˆ×ÑÕ4rf   N)F)Ú__name__Ú
__module__Ú__qualname__Ú
identifierrj   Ústaticmethodrs   rd   rf   rb   r=   r=      s    „ Ø€Jó/ð ñ
ó ñ
rf   r=   c                 ó   ‡ ‡‡— ˆˆ ˆfd„}|S )Nc                 óZ  •— t        «       }|‰	z
  }|j                  t        z  }| j                  di «      }t	        j
                  d«      t	        j
                  d«      t	        j
                  d«      t	        j
                  d«      t	        j
                  d«      |‰dœ|d<   d	t        |«      i|d
<   | j                  di «      }dj                  t	        j
                  d«      «      |d	<   t        ‰d«      r‰j                  |d<   t        ‰d«      r‰j                  j                  d«      |d<   t        ‰d«      rt        ‰j                  «      |d<   t        «       rt        ‰d«      r3‰j                  |d<   n#t        ‰d«      rt!        j"                  «       |d<   t%        |«      | d<   | S )NÚextrar%   r*   r+   r#   r,   )r-   r.   r/   r0   r1   Úexecution_duration_in_millisÚconfigured_timeout_in_secondszgoogle cloud functionsÚurlzgoogle cloud logsÚrequestz	gcp:///{}ÚmethodÚquery_stringzutf-8r$   Údata)r   ÚmicrosecondsÚMILLIS_TO_SECONDSÚ
setdefaultr   r?   Ú_get_google_cloud_logs_urlÚformatrJ   r€   r�   Údecoder   r$   r	   r‚   r   Úremoved_because_raw_datar   )
Úeventr:   Ú
final_timeÚ	time_diffr|   r{   r   Úconfigured_timeoutr3   rZ   s
          €€€rb   Úevent_processorz6_make_request_event_processor.<locals>.event_processor›   s‚  ø€ ô %Ó&ˆ
Ø Ñ-ˆ	à'0×'=Ñ'=Ô@QÑ'QÐ$à× Ñ  ¨"Ó-ˆä$Ÿ[™[¨Ó9Ü$+§K¡K°Ó$>Ü!(§¡Ð-@Ó!AÜ&Ÿ{™{Ð+<Ó=Ü '§¡¨MÓ :Ø,HØ-?ñ+
ˆÐ&Ñ'ð Ô-¨jÓ9ð&
ˆÐ!Ñ"ð —)‘)˜I rÓ*ˆà$×+Ñ+¬G¯K©K¸Ó,HÓIˆ�‰ä�9˜hÔ'Ø )× 0Ñ 0ˆG�HÑä�9˜nÔ-Ø&/×&<Ñ&<×&CÑ&CÀGÓ&LˆG�NÑ#ä�9˜iÔ(Ü!0°×1BÑ1BÓ!CˆG�IÑä#Ô%Ü�y &Ô)Ø"+§.¡.�˜’ä�y &Ô)ô #1×"IÑ"IÓ"K�˜‘ä# GÓ,ˆˆiÑàˆrf   rd   )r3   r�   rZ   rŽ   s   ``` rb   rE   rE   ˜   s   ú€ ö/ðb Ðrf   c           	      ó  — | t        d¬«      z
  }d}dj                  t        j                  d«      t        j                  d«      t        j                  d«      | j	                  |«      |j	                  |«      ¬«      }|S )	zÔ
    Generates a Google Cloud Logs console URL based on the environment variables
    Arguments:
        final_time {datetime} -- Final time
    Returns:
        str -- Google Cloud Logs Console URL to logs.
    é   )Úhoursz%Y-%m-%dT%H:%M:%SZaY  https://console.cloud.google.com/logs/viewer?project={project}&resource=cloud_function%2Ffunction_name%2F{function_name}%2Fregion%2F{region}&minLogLevel=0&expandAll=false&timestamp={timestamp_end}&customFacets=&limitCustomFacetWidth=true&dateRangeStart={timestamp_start}&dateRangeEnd={timestamp_end}&interval=PT1H&scrollTimestamp={timestamp_end}r,   r%   r#   )Úprojectr-   ÚregionÚtimestamp_endÚtimestamp_start)r   r‡   r   r?   Ústrftime)r‹   Úhour_agoÚformatstringr~   s       rb   r†   r†   Ï   s{   € ð œI¨AÔ.Ñ.€HØ'€Lð	9÷
 �fÜ—‘˜MÓ*Ü—k‘k /Ó2Ü�{‰{Ð,Ó-Ø ×)Ñ)¨,Ó7Ø ×)Ñ)¨,Ó7ð ó ð ð €Jrf   ).rP   Úcopyr   r   r   Úosr   Úsentry_sdk.apir   Úsentry_sdk.constsr   Úsentry_sdk.hubr   r	   Úsentry_sdk.tracingr
   Úsentry_sdk._compatr   r   Úsentry_sdk.utilsr   r   r   r   r   Úsentry_sdk.integrationsr   Ú$sentry_sdk.integrations._wsgi_commonr   Úsentry_sdk._typesr   rH   r„   Útypingr   r   r   r   r   r   r   r   re   r=   rE   r†   rd   rf   rb   ú<module>r¥      sŽ   ðÛ 
Ý Ý Ý å )Ý  ß 8Ý ;ß 7÷õ õ 0Ý @å +ð Ð ØÐ áÝ!ÝÝÝÝç=Ñ=á�˜8 C¨ HÑ-Ô.€AòUôp
�[ô 
ò24ónrf   