bg ^ddlZddlmZddlmZmZddlmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZmZmZmZmZdd lmZdd lmZdd lmZdZdZer7ddl m!Z!ddl m"Z"ddl m#Z#ddl m$Z$ddlm%Z%m&Z&m'Z'e"de#de!fZ(dZ)GddeZ*dZ+dZ,dS)N)deepcopy)datetime timedelta)environ)continue_trace)OP)Hub_should_send_default_pii)TRANSACTION_SOURCE_COMPONENT)reraise)AnnotatedValuecapture_internal_exceptionsevent_from_exceptionlogger TimeoutThread) Integration)_filter_headers) TYPE_CHECKINGg?g@@)Any)TypeVar)Callable)Optional)EventProcessorEventHintF.)boundcfd}|S)Nc tj}|t}| ||g|Ri|S|j}t jd}|s!tjd||g|Ri|St|}tj }| 5} t5| | t!|||| dt jdd} |jr9|t&kr.|t&z } t)| |} | dddn #1swxYwYi} t-|dr|j} t1| t2jt jddt6} t jdt jd t jd t jdt jd d |d }|| |5 ||g|Ri|| r| |cdddcdddS#t>$rStAj!}tE||j#ddd\}}|$||tK|YnwxYw | r| |n/#| r| |wxYw dddn #1swxYwYddddS#1swxYwYdS)NFUNCTION_TIMEOUT_SECzOThe configured timeout could not be fetched from Cloud Functions configuration. gcp_regionFUNCTION_REGIONheaders FUNCTION_NAME)opnamesource ENTRY_POINTFUNCTION_IDENTITY GCP_PROJECT) function_namefunction_entry_pointfunction_identityfunction_regionfunction_project)gcp_env gcp_event)custom_sampling_contextgcpF)typehandled)client_options mechanism)hint)&r currentget_integrationGcpIntegrationclientrgetrdebugintrutcnow push_scoperclear_breadcrumbsadd_event_processor_make_request_event_processorset_tagtimeout_warningTIMEOUT_WARNING_BUFFERrstarthasattrr#rr FUNCTION_GCPr start_transactionstopflush Exceptionsysexc_inforoptions capture_eventr )functionhandlerr2argskwargshub integrationr=configured_time initial_timescopetimeout_thread waiting_timer# transactionsampling_contextrQ sentry_eventr9funcs l/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/sentry_sdk/integrations/gcp.py sentry_funcz_wrap_func..sentry_func(sk)).99  4DTDDDVDD D!+&<== E La   4DTDDDVDD Do..(( ^^  ; ,.. + +'')))))1!?L  lGK8I,J,JKKK!%/ +'*@@@#25K#KL%2<%Q%QN#((***% + + + + + + + + + + + + + + +(Gy),, ,#+(?["553 K&-[%A%A,3K ,F,F)05H)I)I'.{3D'E'E(/ M(B(B '   &&5E'   4LTLLLVLL&.&++---IIKKK%       S; ; ; ; ; ; ; ; \!'''"|~~H)= '-~+0U"C"C***&L$ %%l%>>>X&&&&''%.&++---IIKKKK&.&++---IIKKKKK%               S; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; s+M/:B#E) M/)E- -M/0E- 1C M/>M J *M6 M/AK,)L+K,,L0+M,MM M/M M/M M//M36M3)rarcs` rb _wrap_funcre&s*Q Q Q Q Q f c0eZdZdZddZedZdS)r<r4Fc||_dS)N)rG)selfrGs rb__init__zGcpIntegration.__init__s.rfcddl}t|dstjddS|j}t |jj|j_dS)Nr worker_v1zFGcpIntegration currently supports only Python 3.7 runtime environment.)__main__rJrwarningrlreFunctionHandlerinvoke_user_function) gcp_functionsworker1s rb setup_oncezGcpIntegration.setup_oncesl )(((}k22  NX    F)7A  # 88 8 444rfN)F)__name__ __module__ __qualname__ identifierrj staticmethodrsrdrfrbr<r<~sHJ////  \   rfr<cfd}|S)Nctj}| z }|jtz }|di}t jdt jdt jdt jdt jd|d|d<d t|i|d <|d i}d t jd|d <td r j |d <tdrj d|d<tdrtj|d<trtdr j|d<n&tdrt#j|d<t'||d <|S)Nextrar$r)r*r"r+)r,r-r.r/r0execution_duration_in_millisconfigured_timeout_in_secondszgoogle cloud functionsurlzgoogle cloud logsrequestz gcp:///{}method query_stringzutf-8r#data)rrA microsecondsMILLIS_TO_SECONDS setdefaultrr>_get_google_cloud_logs_urlformatrJrrdecoderr#r rr removed_because_raw_datar) eventr9 final_time time_diffr|r{rconfigured_timeoutr2rZs rbevent_processorz6_make_request_event_processor..event_processors_&& - '0'=@Q'Q$  "--$[99$+K $>$>!(-@!A!A&{+<== ' M : :,H-?+ + &' -j99& !"))Ir**$++GK,H,HII 9h ' ' 1 ) 0GH  9n - - M&/&<&C&CG&L&LGN # 9i ( ( D!01B!C!CGI  # % % Ly&)) 1"+.y&)) L#1"I"K"K#G,,i rfrd)r2rrZrs``` rbrErEs1///////b rfc |tdz }d}dtjdtjdtjd||||}|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:%SZaYhttps://console.cloud.google.com/logs/viewer?project={project}&resource=cloud_function%2Ffunction_name%2F{function_name}%2Fregion%2F{region}&minLogLevel=0&expandAll=false×tamp={timestamp_end}&customFacets=&limitCustomFacetWidth=true&dateRangeStart={timestamp_start}&dateRangeEnd={timestamp_end}&interval=PT1H&scrollTimestamp={timestamp_end}r+r$r")projectr,region timestamp_endtimestamp_start)rrrr>strftime)rhour_ago formatstringr~s rbrrsIA....H'L 9  f M**k/22{,-- )),77 )),77    Jrf)-rPcopyrrrosrsentry_sdk.apirsentry_sdk.constsrsentry_sdk.hubr r sentry_sdk.tracingr sentry_sdk._compatr sentry_sdk.utilsr rrrrsentry_sdk.integrationsr$sentry_sdk.integrations._wsgi_commonrsentry_sdk._typesrrHrtypingrrrrrrrrrer<rErrdrfrbrs' (((((((()))))) 88888888;;;;;;&&&&&&0/////@@@@@@++++++/==========8CH-...AUUUp     [   2444nrf