0i#ddlZddlZddlZddlZddlmZddlZddlmZm Z ddl m Z ddl m Z ddlmZmZmZddlmZmZmZmZmZmZmZddlmZer&dd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#ejHdejJddzejLdZ'Gdde Z(dZ)ddZ*dZ+dZ,y)N)HTTPConnection)OPSPANDATA) Integration)add_global_event_processor)EnvironHeadersshould_propagate_traceadd_http_request_source)SENSITIVE_DATA_SUBSTITUTEcapture_internal_exceptionsensure_integration_enabled is_sentry_urllogger safe_repr parse_url) TYPE_CHECKING)Any)Callable)Dict)Optional)List)EventHintz%s.%s.%s)nameversionbuildc eZdZdZedZy)StdlibIntegrationstdlibcDtttd}y)Nctjjt/|j di}t |t r d|vr t|d<|S)Ncontextsruntime) sentry_sdk get_clientget_integrationr setdefault isinstancedict_RUNTIME_CONTEXT)eventhintr#s M/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/stdlib.pyadd_python_runtime_contextz@StdlibIntegration.setup_once..add_python_runtime_context6sQ$$&667HIU ++J;h-)82K*:HY'L)_install_httplib_install_subprocessr)r/s r. setup_oncezStdlibIntegration.setup_once0s"  #  $ r0N)__name__ __module__ __qualname__ identifier staticmethodr3r0r.rr-sJ  r0rctjtjfd}fd}|t_|t_y)NcP|j}|j}|j}tj}|j t  t||r|||g|i|S|} | | jds$|dk(xrdxsdd|||k7xrd|zxsd|} d} t5t| d } dddtjtj|d | r | jntd } | j!t"j$|| p| j!d | j| j!t"j&| j(| j!t"j*| j,|||g|i|} t/|| retj0j3| D]>\} }t5j6dj9| || |j;| |@| |_| S#1swYaxYw)N)zhttp://zhttps://ihttpshttpz://z:%sF)sanitize zauto.http.stdlib.httpliboproriginurlspanzJ[Tracing] Adding `{key}` header {value} to outgoing request to {real_url}.)keyvaluereal_url)hostport default_portr%r&r'rr startswithr r start_spanr HTTP_CLIENTrDr set_datar HTTP_METHOD HTTP_QUERYquery HTTP_FRAGMENTfragmentr get_current_scopeiter_trace_propagation_headersrdebugformat putheader_sentrysdk_span)selfmethodrDargskwargsrJrKrLclientrI parsed_urlrFrvrGrHreal_putrequests r. putrequestz$_install_httplib..putrequestFsyyyy(( &&(  ! !"3 4 < DA #4FtFvF F  8#6#67N#O#/969 $5;; H ( *"8e.getresponsest.5 <#D:4:6: : .!$888B  RYY 0 MM(BII . KKM,.'-/ / KKM,.'-/..s0A B' BB$'C# C C#C C#)rrdrm)rdrmrlrcs @@r.r1r1As7$//O%117r(!+N!,Nr0c||vr||}|||}||||<|S|t|kr||}|||}||||<|S|xr|d}||||<|S)a? given (*args, **kwargs) of a function call, retrieve (and optionally set a default for) an argument by either name or position. This is useful for wrapping functions with complex type signatures and extracting a few arguments without needing to redefine that function's entire type signature. N)len)r^r_rpositionsetdefault_callbackrbs r._init_argumentrrs v~ D\  *$R(B >F4L I CI  (^  *$R(B >DN I ! >%8%> >F4L Ir0ctjjttfd}|tj_tjj ttfd}|tj_tjj ttfd}|tj_y)Nc t|}t||ddxsg}t||dd}d}t|ttfr@t |dkr2t 5dj tt|}ddd| t|}d}tjtj|d5}tjj| D]=\}} |t||d d d }| |d |j!j#ddz<?|r|j%d| |g|i|} |j'd|j(| cdddS#1swYxYw#1swYyxYw)Nr^rcwd dr@!auto.subprocess.stdlib.subprocessrArEenv cDt||StjSN)r*osenviron)xs r.zH_install_subprocess..sentry_patched_popen_init..s$AMq"Jrzz"Jr0 SUBPROCESS_-_zsubprocess.cwdsubprocess.pid)listrrr)tupleror joinmapstrrr%rNr SUBPROCESSrVrWupperreplacerPset_tagpid) r\akwr^ru descriptionryrFkvrbold_popen_inits r.sentry_patched_popen_initz6_install_subprocess..sentry_patched_popen_initst GaVQ/52QE1- dT5M *s4y3,.!hhs3~6 /  #D/K  " "}}6 "446UUV1;(J CDEMAGGI$5$5c3$??@ .4/q/B/B LL)488 41  /.  s E&:B"E2&E/2E;ctjtjd5}|j d|j |g|i|cdddS#1swYyxYwNrx)rBrCr)r%rNrSUBPROCESS_WAITrr)r\rrrFold_popen_waits r.sentry_patched_popen_waitz6_install_subprocess..sentry_patched_popen_waitsY " "!!6  LL)488 4!$11b1    (AA"ctjtjd5}|j d|j |g|i|cdddS#1swYyxYwr)r%rNrSUBPROCESS_COMMUNICATErr)r\rrrFold_popen_communicates r. sentry_patched_popen_communicatez=_install_subprocess..sentry_patched_popen_communicatesY " "((6  LL)488 4(88R8    r) subprocessPopen__init__r rwait communicate)rrrrrrs @@@r.r2r2s%%..N 1>B2C2h!:J%%**N 1>B2C26J&,,88 13HI9J9$DJ r0c8ttjdS)Nr)prefix)rr}r~r9r0r."get_subprocess_traceparent_headersrs "**] ;;r0r|)-r}rsysplatform http.clientrr%sentry_sdk.constsrrsentry_sdk.integrationsrsentry_sdk.scopersentry_sdk.tracing_utilsrr r sentry_sdk.utilsr r r rrrrtypingrrrrrrsentry_sdk._typesrrpython_implementation version_inforr+rr1rrr2rr9r0r.rs  &*/7 !- +H * * ,S--bq12 [[ (S-l>UDp