˺h:ddlmZmZddlmZddlZddlmZmZddlm Z ddl m Z ddl m Z mZmZmZmZddlmZdd lmZdd lmZd Zd Zer7dd lmZddlmZddlmZddlmZddlmZm Z m!Z!ededefZ"dZ#GddeZ$dZ%dZ&dS))datetime timedelta)environN)Hub_should_send_default_pii) Transaction)reraise)AnnotatedValuecapture_internal_exceptionsevent_from_exceptionlogger TimeoutThread) Integration)_filter_headers)MYPYg?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} t1j| dt jdd } || 5 ||g|Ri|| r| |cdddcdddS#t:$rSt=j}tA||j!d d d  \}}|"||tG|YnwxYw | r| |n/#| r| |wxYw dddn #1swxYwYddddS#1swxYwYdS)NFUNCTION_TIMEOUT_SECzOThe configured timeout could not be fetched from Cloud Functions configuration. gcp_regionFUNCTION_REGIONheaderszserverless.function FUNCTION_NAME)opnamegcpF)typehandled)client_options mechanism)hint)$rcurrentget_integrationGcpIntegrationclientrgetr debugintrutcnow push_scoper clear_breadcrumbsadd_event_processor_make_request_event_processorset_tagtimeout_warningTIMEOUT_WARNING_BUFFERrstarthasattrr rcontinue_from_headersstart_transactionstopflush Exceptionsysexc_infor options capture_eventr )functionhandlereventargskwargshub integrationr.configured_time initial_timescopetimeout_thread waiting_timer transactionrBr*funcs {/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/sentry_sdk/integrations/gcp.py sentry_funcz_wrap_func..sentry_func%sak)).99  4@@@@@@ @!+&<== A La   4@@@@@@ @o..(( ^^  ) ,.. + +'')))))1%,WW lGK8I,J,JKKK!%/ +'*@@@#25K#KL%2<%Q%QN#((***! + + + + + + + + + + + + + + +$Gui(( (-%;1 OUW8X8XK&&{33   4HHHHHH&.&++---IIKKK!       3) ) ) ) ) ) ) ) 8!'''"|~~H"6 '-~+0U"C"C###KE4 %%e$%777X&&&&''%.&++---IIKKKK&.&++---IIKKKKK!               3) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) s+K=:B#E) K=)E- -K=0E- 1AK= K% H*K% K=AI:7J)9I::J)>+K%),KK% K=%K) )K=,K) -K==LL)rQrSs` rR _wrap_funcrU#s%? ? ? ? ? B c0eZdZdZddZedZdS)r-r%Fc||_dS)N)r8)selfr8s rR__init__zGcpIntegration.__init__ls.rVcddl}t|dstjddS|j}t |jj|j_dS)Nr worker_v1zFGcpIntegration currently supports only Python 3.7 runtime environment.)__main__r;r warningr\rUFunctionHandlerinvoke_user_function) gcp_functionsworker1s rR setup_oncezGcpIntegration.setup_oncepsl )(((}k22  NX    F)7A  # 88 8 444rVN)F)__name__ __module__ __qualname__ identifierrZ staticmethodrcrTrVrRr-r-isHJ////  \   rVr-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#ddgdgi|d<||d <|S)Nextrar! ENTRY_POINTFUNCTION_IDENTITYr GCP_PROJECT) function_namefunction_entry_pointfunction_identityfunction_regionfunction_projectexecution_duration_in_millisconfigured_timeout_in_secondszgoogle cloud functionsurlzgoogle cloud logsrequestz gcp:///{}method query_stringzutf-8r datar"rem)z!rawxrr)rr2 microsecondsMILLIS_TO_SECONDS setdefaultrr/_get_google_cloud_logs_urlformatr;rxrydecoderr rrzr ) rFr* final_time time_diffrtrkrwconfigured_timeout gcp_eventrLs rRevent_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  # % % Uy&)) 1"+.y&)) U#1e>Q>Q>Q=R5S"T"T"i rVrT)rrrLrs``` rRr6r6s1///////b rVc |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}rnr!r)projectroregion timestamp_endtimestamp_start)rrrr/strftime)rhour_ago formatstringrvs rRrrsIA....H'L 9  f M**k/22{,-- )),77 )),77    JrV)'rrosrrAsentry_sdk.hubrrsentry_sdk.tracingrsentry_sdk._compatr sentry_sdk.utilsr r r r rsentry_sdk.integrationsr$sentry_sdk.integrations._wsgi_commonrsentry_sdk._typesrr9r~typingrrrrrrrrrUr-r6rrTrVrRrs(((((((( 88888888******&&&&&&0/////@@@@@@""""""/==========8CH-...ACCCL     [   2444nrV