0isfddlZddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z m Z m Z mZmZddlZddlZddlmZmZddlmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)dd l*m+Z+dd l,m-Z-m.Z.dd l/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5dd l6m7Z7m8Z8ddl9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBmCZCmDZDddlEmFZFddlGmHZHe rnddl mIZIddl mJZJddl mKZKddl mLZLddl mMZMddl mNZNddl mOZOddlPmQZQmRZRmSZSmTZTmUZUmVZVddl6mWZWddlXmYZYddlZm[Z[dd l\m]Z]dd!l,m^Z^dd"l_m`Z`ddlmZeOd#eW$Zaed%Zbd&e4d'e4d(gd)Zcd*Zd eeZfGd+d,ZiGd-d.eiZjGd/d0eiZkdd1l m Z e rGd2d3e5e eleIfZmGd4d5e5ekZnyd6Zmd7Zny#eg$rehZfY`wxYw)8N)Mapping)datetimetimezone) import_module) TYPE_CHECKINGListDictcastoverload)PY37check_uwsgi_thread_support)MetricsBatcher)AnnotatedValue ContextVarcapture_internal_exceptionscurrent_stacktrace env_to_boolformat_timestamp get_sdk_name get_type_nameget_default_release handle_in_app is_geventloggerget_before_send_logget_before_send_metrichas_logs_enabledhas_metrics_enabled) serialize)trace)BaseHttpTransportmake_transport)SPANDATADEFAULT_MAX_VALUE_LENGTHDEFAULT_OPTIONS INSTRUMENTERVERSIONClientConstructor)_DEFAULT_INTEGRATIONSsetup_integrations)DedupeIntegration)SessionFlusher)Envelope)setup_continuous_profiler)has_profiling_enabledProfilesetup_profiler) EventScrubber)Monitor)Any)Callable)Optional)Sequence)Type)Union)TypeVar)EventHintSDKInfoLogMetricEventDataCategory) Integration)Scope)Session)SpotlightClient) Transport LogBatcherI)boundclient_init_debugz sentry.pythonzpypi:sentry-sdk)nameversion)rKrLpackagesc|r)t|dttfs|d |d}|dd}nd}t|dkDr t dt t }t |i|}||jd||d<|jD]\}}||vrt d||||<|d"tjjd|d<|d t|d<|d&tjjd xsd |d<|d 1ttjjd d xsd|d <|d'ttdrtj|d<|dt j"|d<|d tj$}||d<|dd ur |dd|d<|dt)|ddn|d|d<|dr-t|dt*st-j.dd|d<|d1ttjjdd xsd|d<|dt1j2dt4d |S#t&$rd}YwxYw)!Nrz+Only single positional argument is expecteddsnzUnknown option SENTRY_DSNrelease environmentSENTRY_ENVIRONMENT productiondebug SENTRY_DEBUGTstrictF server_name gethostname instrumenter project_rootenable_tracingtraces_sample_rate?event_scrubbersend_default_pii)rbsocket_optionszxIgnoring socket_options because of unexpected format. See urllib3.HTTPConnection.socket_options for the expected format. keep_aliveSENTRY_KEEP_ALIVEzVThe `enable_tracing` parameter is deprecated. Please use `traces_sample_rate` instead.) stacklevel) isinstancebytesstrlen TypeErrordictr%getitemsosenvironrrhasattrsocketr[r&SENTRYgetcwd Exceptionr2listrwarningwarningswarnDeprecationWarning)argskwargsrPrvoptionskeyvaluer]s @/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/client.py _get_optionsrVs DGeS\2d1go1gABx 4y1}EFF o BD#F#G 7;;u-5mmo U b=389 93 &  %yJJNN<05  )}+-9  - JJNN+?@PL= '{!"**.."@NWRW7  - WV]%C"..0= .!)00> .! 99;L*> t#+?(@(H#&   #,./7R@R=S    Jr2B/CT$J G  $  ,  ':;D I RU < ' d  IC L s I I-,I-ceZdZdZdZddZdZdZedZ dZ dZ d Z d Z d Zd Zered ZedZdZdZdZdZdZy) BaseClientzp .. versionadded:: 2.0.0 The basic definition of a client that is used for sending data to Sentry. NcZ||nt|_d|_d|_d|_d|_yN)r%r transportmonitor log_batchermetrics_batcher)selfrs r__init__zBaseClient.__init__s.")"5w?  #c diiSNrrr|r}s r __getstate__zBaseClient.__getstate__s 2rcyrrrs r __setstate__zBaseClient.__setstate__ rcyrrrs rrPzBaseClient.dsnsrcy)NFrrs rshould_send_default_piiz"BaseClient.should_send_default_piisrcy)u .. versionadded:: 2.0.0 Returns whether the client is active (able to send data to Sentry) Frrs r is_activezBaseClient.is_activesrcyrrrs r capture_eventzBaseClient.capture_eventrcyrr)rlogs r _capture_logzBaseClient._capture_logrrcyrr)rmetrics r_capture_metriczBaseClient._capture_metricrrcyrrrs rcapture_sessionzBaseClient.capture_sessionrrcyrrr name_or_classs rget_integrationzBaseClient.get_integration rcyrrrs rrzBaseClient.get_integrationrrcyrrrs rrzBaseClient.get_integrationrrcyrrrs rclosezBaseClient.closerrcyrrrs rflushzBaseClient.flushrrc|Srrrs r __enter__zBaseClient.__enter__ rcyrrrexc_type exc_valuetbs r__exit__zBaseClient.__exit__rrr)__name__ __module__ __qualname____doc__ spotlightrrrpropertyrPrrrrrrrr rrrrrrrrrrs I$           rrceZdZdZy)NonRecordingClientz .. versionadded:: 2.0.0 A client that does not send any events to Sentry. This is used as a fallback when the Sentry SDK is not yet initialized. N)rrrrrrrrr s   rrceZdZdZfdZdZdZdZdZdZ dZ e d Z d Z d Z dd Zd ZdZ ddZdZdZdZeredZedZdZ ddZ ddZdZdZxZS)_ClientaI The client is internally responsible for capturing the events and forwarding them to sentry through the configured transport. It takes the client options as keyword arguments and optionally the DSN as first argument. Alias of :py:class:`sentry_sdk.Client`. (Was created for better intelisense support) c`tt| t|i||j y)Nr)superrr get_options _init_impl)rr|r} __class__s rrz_Client.__init__s) gt%k4.J6.J%K rcd|jiSrrrs rrz_Client.__getstate__#s4<<((rc8|d|_|jyr)rr)rstates rrz_Client.__setstate__'sY'  rc|D]b}d}|d}|jdd\}} t|}t||}t||t |t j d|dy#t$r |jdd\}}t|}t||} t| |}t| j|} t |} | ttfvr t| } t| || t||| t j d|n-#t$r!} t jd|| Yd} ~ nd} ~ wwxYwYEt$r"} t jd|| Yd} ~ jd} ~ wwxYw)z Instruments the functions given in the list `functions_to_trace` with the `@sentry_sdk.tracing.trace` decorator. Nqualified_name.rOzEnabled tracing for %szWCan not enable tracing for '%s'. (%s) Please check your `functions_to_trace` parameter.)rsplitrgetattrsetattrr rrVmodule_not_found_errortype__dict__ staticmethod classmethodrvrx) rfunctions_to_tracefunction class_namefunction_qualname module_name function_name module_obj function_obj class_obj function_typetraced_functiones r_setup_instrumentationz_Client._setup_instrumentation,sr +HJ ()9 : ):)A)A#q)I &K' +;7 &z=A  M53FG 57HI+* /:.@.@a.H+K!.{!;J ' J ?I#*9m#DL$(););M)J$KM&+L&9O${(CC*6*GI}oFJ I>LL!9;LM NNq) m% sIAA)) E23B$DE2 E!D=8E2=EE2E2E--E2ctjd}fd} d(fd } tjjdt j_d_j r)jdrtj _t|_ d_ tjrddl m }||| _ d_tjrt!|| _d }jd |vrt#d j%|jd jddrOt'j(dt*j,jd<dt.vrt/j0dt3jdjdjdjdj_jjd}|Edt6j8vr3t6j8d}t;|d}||n|jd<jjdrkddlm}|j_ jds?d} djd<| jd<| jd <| jd!<tCtEj4jG} | tHd"<t'j(d#| tKjr tMjn tQjtH|%tj|jSjjd'gj s;js/tKjstUj tVr tYyy#tN$r } t'j(d$| Yd} ~ d} ~ wwxYw#tN$r } t'j(d&| Yd} ~ d} ~ wwxYw#tj|wxYw))NFcVjjj|yyr)rcapture_envelope)envelopers r_capture_envelopez-_Client._init_impl.._capture_envelopecs$~~)//9*rc\jjj|||yy)Nreason data_categoryquantity)rrecord_lost_event)rrrrs r_record_lost_eventz._Client._init_impl.._record_lost_evenths4 ~~)00!"/%1*rrVenable_backpressure_handling) capture_funcrrF)rrecord_lost_func)alwaysneversmallmediummax_request_body_sizez:Invalid value for max_request_body_size. Must be one of {} _experimentsotel_powered_performancezA[OTel] Enabling experimental OTel-powered performance monitoring.r\zJsentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration integrationsdefault_integrationsauto_enabling_integrationsdisabled_integrations) with_defaultswith_auto_enabling_integrationsrrrSENTRY_SPOTLIGHTTrX)setup_spotlightrPcy)Nr`r)_args_kwargss rz$_Client._init_impl..s3rrb error_samplertraces_samplerprofiles_samplerrKzSetting SDK name to '%s'zCan not set up profiler. (%s))sdk_inforz(Can not set up continuous profiler. (%s)r)rO)-_client_init_debugrnsetrr"rrr3r,session_flusherrrsentry_sdk._log_batcherrGrrr ValueErrorformatrrVr&OTELr)appendr*rrprqrsentry_sdk.spotlightrrrrwkeysSDK_INFOr/r1rvr.rrhr!r ) r old_debugrrrGrspotlight_configspotlight_env_valuer sample_allsdk_namers ` rrz_Client._init_impl_s&**51  : f .  " "4<<#8 9+DLL9DNDL~~<< >?#*4>>#:DL#1?P#QD #D  ->#-!2%7$ $(D "4<<0'5!2%7($ %K !||34"**,L&(jj1C&D##./B4#P (3%, [) || ,A!0!>||E*!>J7;DLL!344>DLL15?DLL!127ADLL!34#D):):)?)?)A$BCH'HV  LL3X >$T\\2E"4<<0P- !)%6  " "9 - ##DLL$4$45I2$NO LL$T\\2$..*;< ' ( =+!ELL!@!DDE!PLL!KQOOP  " "9 -sZLQ!P Q!P5 P2P-(Q!-P22Q!5 Q>QQ!QQ!!Q8cy)rTrrs rrz_Client.is_activesrc@|jjdxsdS)z .. versionadded:: 2.0.0 Returns whether the client should send default PII (Personally Identifiable Information) data to Sentry. rbF)rrnrs rrz_Client.should_send_default_piis|| 23r|D]}|jd"d}|jd#i}|s*||j<vs9t@jB|vsLt%|t@jBd$|j<|i|t@jB<|!t%|jdgd$|i|d<|#t%|jd dgid$|i|d <|nt d%tEt d&||jjd'|jjd|jjd()}|jd*}|||jddk7rd}t'5|||xsi}ddd|ctGjHd+|jr|jjd*d|jdrtKjL|}|jd,}|(|%|jddk(rd}t t ttttf|jdg}t'5|||xsi}ddd|`tGjHd-|jr|jjd*d.|jjd*d|d z/nM|t |jdgz } | d kDr*|j|jjd*d| /|}|S#1swYwxYw#1swYxYw#1swYxYw)0N timestampr transactionspansevent_processorerrorrspanrO)rrr_dropped_spans breadcrumbsvaluesattach_stacktrace exception stacktracethreadsinclude_local_variablesTmax_value_length)r0r1F)r.crashedcurrent)rRrSrZdistsdkrplatformpythonin_app_excludein_app_includer]raspan_iddatarkr;zDict[str, Any]r custom_repr)rr1r< before_sendzbefore send dropped eventbefore_send_transactionz%before send transaction dropped event)rrr)'rnrnowrutcrkr rr rjobjectapply_to_eventrrrpop_n_breadcrumbs_truncatedrhrrrr$striprmrsortedrrr scrub_event_gen_ai_original_message_countrwr#GEN_AI_REQUEST_MESSAGESrrinfor+reset_last_seen)reventhintscopeprevious_total_spansprevious_total_breadcrumbsis_transaction spans_beforeevent_ spans_delta dropped_spansr*r+rr rar$r(r: span_datar= new_eventr>s r_prepare_eventz_Client._prepare_events $%)" 99[ ! )!)hll!;E+ 6*m;  tDc6k):$;UYYwPR=STUL))%t||DF~>>NN44)8F}G5&88-*0%1A%59 E&T$sF{+,eii.DE*K+/dnn6P00%Vk1"II&6:[HMq '3m'C$--1#ii r: &k>B OOHb1 K%"@"@@+  015(E)&,.*<8< 8H8H$=t9"261A1A$68P2" +(-'+  $i /$CCyy~%$,,s*;*G c!2399;c C 99U  #H~H'-d.?.?.D.D.F'GH^ $#E%L 99Z ( (E*   LL) * LL) * LL (    !\\*:;N**51  !E!EIIgr*E%&!D"hhy$7G $ 4I#u'K'KK$<< IFT%h&F&FG"E$H$H$QRG ("B"BC" ++ '2&0D(EE'N & 1#1 -(B823$E-   )51*.,,*:*:;R*S%)\\%5%56H%I $ 0 0 ? Ell=1  #! &!]2I,.'tzr: /  78>>NN44%W599[)%557E"&,,/H"I # /! &!]2ItDc6k):$;UYYwPR=STUL,.3E4:2F /  CD>>NN44,M5NN44,&,!-!15 +Sw1K-LL ?t~~'ANN44,F[5E M/.l/.4/.s%A["[([5[%([25[>c|jd}|y|d}t|d}|djd|}|jdD]-}t |t r ||k(s||k(syt ||s-yy)Nexc_infoFrr ignore_errorsT)rnrrrrhrj issubclass)rrLrMrZr&error_type_nameerror_full_name ignored_errors r_is_ignored_errorz_Client._is_ignored_errors88J'   ' 4%-a[%;%;_M!\\/:M-- O3}7We]3;rc|jddk(}|ry|duxr |j }|ry|j||}|ryy)Nrr#TF)rn_should_capturer`)rrLrMrNrQignoring_prevents_recursionignored_by_config_options rrbz_Client._should_capturesX6*m; &+4&7&U@U@U>W%78  rct|xsd}|j|||sy|jdd}|jd}|#t j j x|d<}|j|||}|y|r |jnd}|r|j|||jddk(}|jddk(} |s| s|j||sy|jd} |jd ijd xsi} | jd i} |dttjtjd } | r| | d <t!| }|rMt#|t$r+|j'|j)||j*|j-|n%| r|j/|n|j1|| xsdD]!}|j3|j5#d}|j6r|j6j9||}|j:|j:j9||}|S)aCaptures an event. :param event: A ready-made event that can be directly sent to Sentry. :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object. :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events. :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help. rNprofileevent_idrr#check_in attachmentscontextsr dynamic_sampling_context)rsent_at)rw)rmrbrCrnuuiduuid4hexrX_sessionrrqrrr?rr@r-rhr0 add_profileto_jsonradd_transaction add_checkin add_eventadd_itemto_envelope_itemrrr)rrLrMrNrr event_optr}rQ is_checkinr trace_contextrrwr attachment return_values rrz_Client.capture_eventMs4"DJB##E47))It,99Z(  +/::<+;+; ;E* ''tU;  %*%..t   + +GU ;"v.-?]]6*j8 --eT:hh}- ! j"599'BHb #0#4#45OQS#T "*-' X\\(BC  $7GG G, '7+$$W__Y %MN  $ $Y /    +   y )%++J   j99; <, >> NN + +H 5#L >> % NN + +H 5#Lrc~t|jr|ytj}tj}t d|dd<t d|dd<|jj d}|+tj|dvr||dtj<|jj d}|d|dvr||dd<|jj d }|d |dvr||dd <|j}|j d }|j d } ||j d ||d <| d |dvr| |dd <|j6dD]1\} } | |jvs| |dvs|j| |d| <3|jj dd} | r9tjd|j dd|j dt|j} | | |i}|y|jr|jj|yy)NrK attributessentry.sdk.namerLsentry.sdk.versionrZrSsentry.environmentrRsentry.releasetrace_idr:zsentry.trace.parent_span_id)zuser.idid)z user.nameusername)z user.emailemailrVFz[Sentry Logs] [ severity_text] body)rr sentry_sdkget_current_scopeget_isolation_scoperrnr#SERVER_ADDRESSget_trace_context_userrrVrradd)rr current_scopeisolation_scoperZrSrRrrr: log_attributeuser_attributerVbefore_send_logs rrz_Client._capture_logsi - "446 $88:/7/?L+,2:92EL./ll&&}5  "x'>'>c,FW'W9DC h55 6ll&&}5  "';3|CT'T6AC 2 3,,""9-  #33|;L#L29C . /%779  $$Z0##I.  CGGJ$7$?&C O  -S5FF?FC ; <  ,2- ~ #o&;&;;%S->>7F7L7L&8C %m42   %0  LL!#''/":!;2cggfo=NO .dll;  &!#r*C ;         % rc pt|jr|ytj}tj}t d|dd<t d|dd<|jj d}|+tj|dvr||dtj<|jj d}|d|dvr||dd<|jj d }|d |dvr||dd <|j}|j d }|j d } |xsd |d <| | |d <|j6dD]1\} } | |jvs| |dvs|j| |d| <3|jj dd} | rKtjd|j dd|j dd|j dt|j} | | |i}|y|jr|jj|yy)NrKrrrLrrZrSrrRrrr:z$00000000-0000-0000-0000-000000000000rrVFz[Sentry Metrics] [rrz: r)rrrrrrrnr#rrrrrVrrr)rrrrrZrSrRrrr:metric_attributerrVbefore_send_metrics rrz_Client._capture_metrics^"4<<0FN "446 $88:2:62B|./5=i5H|12ll&&}5  #''vl/CCF<()9:5   %0  LL$VZZ%7$86::f;M:NbQWQ[Q[\cQdPef 4DLLA  )'3F >      $ $V , rc~|jstjdy|jj |y)Nz3Discarded session update because of missing release)rRrrJr add_session)rr}s rrz_Client.capture_session&s,  KKM N  , ,W 5rcyrrrs rrz_Client.get_integration2rrcyrrrs rrz_Client.get_integration7rrct|tr|}n$|j |j}n td|jj |S)zReturns the integration for this client by name or class. If the client does not have that integration then `None` is returned. zIntegration has no name)rhrj identifierrrrn)rrintegration_names rrz_Client.get_integration<sP mS ),   % % 1,77 67 7  $$%566rc|j|j|||jj|j|jj|j |j j|j r|j j|jjd|_yy)z Close the client and shut down the transport. Arguments have the same semantics as :py:meth:`Client.flush`. Ntimeoutcallback)rrrkillrrrrrrs rrz _Client.closeMs >> % JJwJ :  % % '+  %%'##/$$))+|| !!# NN   !!DN &rcF|j||jd}|jj|j|jj|j |j j|jj||yy)a# Wait for the current events to be sent. :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used. :param callback: Is invoked with the number of pending events and the configured timeout. Nshutdown_timeoutr)rrrrrrrs rrz _Client.flushcs >> %,,'9:  & & (+  &&(##/$$**, NN 8 D &rc|Srrrs rrz_Client.__enter__zrrc$|jyr)rrs rrz_Client.__exit__~s  rr)NN)rrrrrrrrrrrrrPrXr`rbrqrrrrrrr rrrrr __classcell__)rs@rrrs ) 1fH)T=## GR4 ,.`% T SjB&H>-@6        7&"0E.rr)rc eZdZy)rNrrrrrrrr rrc eZdZy)ClientNrrrrrrrrrctSr)rrrrr r sr?r@rAsentry_sdk.scoperBsentry_sdk.sessionrCrrDrErrGrHrrrModuleNotFoundErrorrrv ImportErrorrrrrjrrrrrrsu #'#<<?6$,$BN<.(M .&VV3&*4.2:;'A 34 +@A L^)0 ZZz  l jl ^! 'c3h  "G (*K Fc)()s F&&F0/F0