0iddlZddlZddlZddlmZmZddlmZddlmZddl m Z ddl m Z m Z ddl mZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZdd lmZmZmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7ddl8Z8ddl8m9Z9e9rddl:m;Z;ddl8mZ>ddl8m?Z?ddl8m@Z@ddl8mAZAddl8mBZBddl8mCZCddl8mDZDddl8mEZEddl8mFZFdd l8mGZGdd!lHmIZIdd"lmJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSdd#l)mTZTddlUZUeDd$ZVeFd%ZWeFd&e=d'elmmnZne9rddlmZUyy)?N)copydeepcopy)deque)contextmanager)Enum)datetimetimezonewraps)chain)AnnotatedValue) Attachment)DEFAULT_MAX_BREADCRUMBS FALSE_VALUES INSTRUMENTER) FlagBufferDEFAULT_FLAG_CAPACITY)get_profiler_id!try_autostart_continuous_profiler!try_profile_lifecycle_trace_start)Profile)Session)Baggagehas_tracing_enablednormalize_incoming_dataPropagationContext)BAGGAGE_HEADER_NAMESENTRY_TRACE_HEADER_NAMENoOpSpanSpan Transaction)capture_internal_exceptioncapture_internal_exceptions ContextVardatetime_from_isoformatdisable_capture_eventevent_from_exceptionexc_info_from_errorlogger) TYPE_CHECKING)Mapping)Any)Callable)Deque)Dict) Generator)Iterator)List)Optional) ParamSpec)Tuple)TypeVar)Union)Unpack) BreadcrumbBreadcrumbHintErrorProcessorEventEventProcessorExcInfoHint LogLevelStrSamplingContextType)TransactionKwargsPRF.)boundTisolation_scope)default current_scopeceZdZdZdZdZdZy) ScopeTypecurrent isolationglobalmergedN)__name__ __module__ __qualname__CURRENT ISOLATIONGLOBALMERGED?/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/scope.pyrMrMssGI F FrZrMc eZdZddZdZdZy) _ScopeManagerNcg|_yN) _old_scopes)selfhubs r[__init__z_ScopeManager.__init__{s rZctj}|jj||j }t j ||Sr_)Scopeget_isolation_scoper`appendfork_isolation_scopeset)rarI forked_scopes r[ __enter__z_ScopeManager.__enter__sF335 0&++- \*rZcb|jj}tj|yr_)r`poprirj)raexc_type exc_valuetb old_scopes r[__exit__z_ScopeManager.__exit__s$$$((* Y'rZr_)rRrSrTrcrlrsrYrZr[r]r]zs (rZr]c.tj|yr_)global_event_processorsrg) processors r[add_global_event_processorrws""9-rZc|ayr_ _external_propagation_context_fnfns r[%register_external_propagation_contextr}s (*$rZcdayr_ryrYrZr[#remove_external_propagation_contextrs (,$rZc&tr tSdSr_ryrYrZr[ get_external_propagation_contextrs/O(*TXrZc0t||jS)N)fsetdoc)property__doc__r{s r[ _attr_setterrs  ,,rZc.tfd}|S)Ncl|jsy d|_|g|i|d|_S#d|_wxYw)NFT)_should_capture)raargskwargsr|s r[wrapperz!_disable_capture..wrappersA##  (#(D d,T,V,#'D 4D s* 3r )r|rs` r[_disable_capturers  2Y(( NrZc8eZdZdZdZdPdZdZedZedZ edZ ed Z ed Z ed Z dPd Zed ZdQdZdZdZdZdQdZdZdZdZdZdZdZdZdZdZedZdZ edZ!e"dZ#e#jHd Z#dQd!Z%ed"Z&d#Z'e"d$Z(e(jHd%Z(e"d&Z)e)jHd'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1 dRd0Z2dPd1Z3de4jjdfd2Z6e4jjfd3Z7 dSd4Z8dPd5Z9dPd6Z:dPd7Z;d8Zd;Z?d<Z@ dQd=ZAd>ZBd?ZCd@ZDdAZEdBZFdCZGdDZHdEZIdFZJdGZKdHZLdIZMdJZNeO dQdKZPdLZQ dTdMZRdNZSe"dOZTy)UrezaThe scope holds extra information that should be sent with all events that belong to it. )_level_name _fingerprint _transaction_transaction_info_user_tags _contexts_extras _breadcrumbs_n_breadcrumbs_truncated_gen_ai_original_message_count_event_processors_error_processorsr_span_session _attachments_force_auto_session_tracking_profile_propagation_contextclient_type_last_event_id_flagsNc||_g|_g|_d|_d|_d|_i|_t|_||j||j|j}|j|y)Nr) incoming_data) rrrrrrrNonRecordingClientr set_clientclear_load_trace_data_from_envgenerate_propagation_context)ratyrincoming_trace_informations r[rczScope.__init__s~ !#!# $(!()%.0+(*   OOF # %)%C%C%E" ))8R)SrZctj|j}|j|_|j|_|j |_|j |_|j|_|j|_|jj|_ |j|_ |jj|_ |jj|_ |jj|_t|j|_|j |_|j"j|_|j$j|_|j&j|_|j(|_|j*|_|j,|_|j.|_|j0|_|j2j|_|j4|_|j6|_t9|j:|_|S)zs Returns a copy of this scope. This also creates a copy of all referenced data structures. )object__new__ __class__rrrrrrrrrrrrrrrrrrrrrrrrrrr)rarvs r[__copy__zScope.__copy__s ^^DNN +::KK KK ::++++#55::<::::??$~~**, \\&&( t001&*&C&C#,0,O,O,T,T,V)#55::<#55::<"&";";!11::mm *.*K*K'++002mm  //T[[)  rZctj}|/ttj}tj ||S)zM .. versionadded:: 2.0.0 Returns the current scope. r)_current_scopegetrerMrUrj)clsrKs r[get_current_scopezScope.get_current_scope&s<'**,  !Y%6%67M   } -rZc.tj|y)z .. versionadded:: 2.0.0 Sets the given scope as the new current scope overwriting the existing current scope. :param new_current_scope: The scope to set as the new current scope. N)rrj)rnew_current_scopes r[set_current_scopezScope.set_current_scope5s ,-rZctj}|/ttj}tj ||S)zO .. versionadded:: 2.0.0 Returns the isolation scope. r)rirrerMrVrj)rrIs r[rfzScope.get_isolation_scope@s<+..0  "#y':':;O   1rZc.tj|y)z .. versionadded:: 2.0.0 Sets the given scope as the new isolation scope overwriting the existing isolation scope. :param new_isolation_scope: The scope to set as the new isolation scope. N)rirj)rnew_isolation_scopes r[set_isolation_scopezScope.set_isolation_scopeOs 01rZcNtttjatS)zL .. versionadded:: 2.0.0 Returns the global scope. r) _global_scopererMrWrs r[get_global_scopezScope.get_global_scopeZs   !Y%5%56MrZc6|jjS)a .. versionadded:: 2.2.0 Returns event ID of the event most recently captured by the isolation scope, or None if no event has been captured. We do not consider events that are dropped, e.g. by a before_send hook. Transactions also are not considered events in this context. The event corresponding to the returned event ID is NOT guaranteed to actually be sent to Sentry; whether the event is sent depends on the transport. The event could be sent later or not at all. Even a sent event could fail to arrive in Sentry due to network issues, exhausted quotas, or various other reasons. )rfrrs r[ last_event_idzScope.last_event_idhs&&(777rZc|r |r tdtttn t}tj |_tj}||j|tj}||j|||k7r||k7r|j||(t|r |||S|j||S|r|jdi||S)z Merges global, isolation and current scope into a new scope and adds the given additional scope or additional scope kwargs to it. zcannot provide scope and kwargsrY) TypeErrorrrrerMrXrrirupdate_from_scopercallableupdate_from_kwargs)raadditional_scopeadditional_scope_kwargs final_scoperIrKs r[ _merge_scopeszScope._merge_scopesys  7=> >-:-Fd=)EG %,, *..0  &  ) )/ :&**,  $  ) )- 8 = T_%<  ) )$ /  '() - --.>? % *K * * E-D ErZctj} |j}||j r|St j} |j}||j r|S t j}||j r|StS#t$rd}YwxYw#t$rd}YawxYw#t$rd}YMwxYw)a, .. versionadded:: 2.0.0 Returns the currently used :py:class:`sentry_sdk.Client`. This checks the current scope, the isolation scope and the global scope for a client. If no client is available a :py:class:`sentry_sdk.client.NonRecordingClient` is returned. N)rrrAttributeError is_activerirr)rrKrrIs r[ get_clientzScope.get_clients'**,  "))F  &"2"2"4M*..0 $++F  &"2"2"4M "))F  &"2"2"4M!##/ F  F  F s5 B B+,B< B('B(+ B98B9< C  C c6|||_yt|_y)z .. versionadded:: 2.0.0 Sets the client for this scope. :param client: The client to use in this scope. If `None` the client of the scope will be replaced by a :py:class:`sentry_sdk.NonRecordingClient`. N)rr)rars r[rzScope.set_clients!' 2f 8J8L rZct|}|S)zP .. versionadded:: 2.0.0 Returns a fork of this scope. )r)rarks r[rhz Scope.forksDz rZcd}tjjdxsdj}|tv}|ri}tjjdr*tjjdxsd|t <tjjdr*tjjdxsd|t <|xsdS)z Load Sentry trace id and baggage from environment variables. Can be disabled by setting SENTRY_USE_ENVIRONMENT to "false". NSENTRY_USE_ENVIRONMENT SENTRY_TRACESENTRY_BAGGAGE)osenvironrlowerrrr)rarsentry_use_environmentuse_environments r[rzScope._load_trace_data_from_envs &*" JJNN3 4 : %' 1 D )+ &zz~~n-JJNN>28b++CDzz~~./JJNN#34:++>?*1T1rZc"t|_y)zt Creates a new propagation context and sets it as `_propagation_context`. Overwriting existing one. N)rrras r[set_new_propagation_contextz!Scope.set_new_propagation_contexts %7$8!rZc|rtj|}|||_|jtj k7r|j|j yyy)a Makes sure the propagation context is set on the scope. If there is `incoming_data` overwrite existing propagation context. If there is no `incoming_data` create new propagation context, but do NOT overwrite if already existing. N)rfrom_incoming_datarrrMrUr)rarpropagation_contexts r[rz"Scope.generate_propagation_contextsZ "4"G"G "V ".,?) ::** *((00021 +rZc|jy|j}||j|j_|jjS)z Returns the Dynamic Sampling Context from the Propagation Context. If not existing, creates a new one. N)r get_baggagedynamic_sampling_context)rabaggages r[get_dynamic_sampling_contextz"Scope.get_dynamic_sampling_context sU  $ $ ,""$  002  % % >((AAArZcN|j}t|jr&|j|jj S|j 1|j j d|j j}|S|jjS)z Returns the Sentry "sentry-trace" header (aka the traceparent) from the currently active span or the scopes Propagation Context. -) rroptionsspanto_traceparentrtrace_idspan_idrfget_traceparent)rarrr traceparents r[rzScope.get_traceparents " v~~ .4993H99++- -  $ $ 0))22))11K '')99;;rZc\|j}t|jr&|j|jj S|j 8|j j }|tj|St|S|jjS)z Returns the Sentry "baggage" header containing trace information from the currently active span or the scopes Propagation Context. ) rrrr to_baggagerrr from_optionsrfr)rarrrrs r[rzScope.get_baggage2s " v~~ .4993H99'') )  $ $ 0))BB %(/++D11788'')5577rZcNt|jjr&|j|jj St }|r |\}}||dS|j }|iS|j|j|j|jdS)zR Returns the Sentry "trace" context from the Propagation Context. )rr)rrparent_span_idr) rrrrget_trace_contextrget_active_propagation_contextrrrr)raexternal_propagation_contextrrrs r[rzScope.get_trace_contextKs t088 9djj>T:://1 1(H'I$ ' < Hg (W= ="AAC  &I,44*221@@(,(I(I(K   rZc|jdd}|tjdd}|j}||dtd|dz }|j }||dt d|jdz }|S)z Return meta tags which should be injected into HTML templates to allow propagation of trace information. rNzaThe parameter `span` in trace_propagation_meta() is deprecated and will be removed in the future.rz )rnr)warningrrrr serialize)rarrrmeta sentry_tracers r[trace_propagation_metazScope.trace_propagation_metads zz&$'   NNs ++-  # ( D ""$   #!!# D  rZc#K|jS|j}| t|f|j}|$t |j }t |fyyyw)zz Creates a generator which returns the `sentry-trace` and `baggage` headers from the Propagation Context. N)rrrrrrr)rardscrs r[ iter_headerszScope.iter_headerssm  $ $ 0..0K&. ;;335C!#,002)722 1sA!A#c/fK|j}|jjdstjdt dy|j dd}|xs |j}t|jr||jD]}|y|j|jD]}|y|j}|j|jD]}|y|j}|j|jD]}|yyw)z Return HTTP headers which allow propagation of trace data. If a span is given, the trace data will taken from the span. If no span is given, the trace data is taken from the scope. propagate_tracesz_The `propagate_traces` parameter is deprecated. Please use `trace_propagation_targets` instead. stacklevelNr) rrrwarningswarnDeprecationWarningrnrrrrrrf)rarrrrheaderrKrIs r[iter_trace_propagation_headersz$Scope.iter_trace_propagation_headerss"~~!!"45 MMq"  zz&$' tyy v~~ .43C++- . ((4"//1F L2!% 6 6 8  55A"/"<"<">$ #?'+&>&>&@O&;;G&5&B&B&DF"(L'EHsD/D1c|j |jS|j}|j |jS|j}|j |jSyr_)rrrf)rarKrIs r[rz$Scope.get_active_propagation_contextsi  $ $ 0,, ,..0  - - 9 55 5224  / / ;"77 7rZcd|_d|_d|_i|_d|_i|_i|_i|_g|_|jd|_ d|_ d|_ d|_ d|_d|_d|_d|_y)zClears the entire scope.NT)rrrrrrrrrclear_breadcrumbsrrrrrrrrrs r[rz Scope.clears   !#     #  ,0) $(!# rZc<tjd||_y)z When set this overrides the level. .. deprecated:: 1.0.0 Use :func:`set_level` instead. :param value: The level to set. zIDeprecated: use .set_level() instead. This will be removed in the future.N)r)rrravalues r[levelz Scope.levels  W  rZc||_y)zX Sets the level for the scope. :param value: The level to set. Nrrs r[ set_levelzScope.set_levels  rZc||_y)z0When set this overrides the default fingerprint.N)rrs r[ fingerprintzScope.fingerprints "rZcv|jy|jjy|jjS)z8Return the transaction (root span) in the scope, if any.N)rcontaining_transactionrs r[ transactionzScope.transactions8 ::  :: , , 4zz000rZctjd||_|jr3|jjr||jj_yyy)zrWhen set this forces a specific transaction name to be set. Deprecated: use set_transaction_name instead.z`Assigning to scope.transaction directly is deprecated: use scope.set_transaction_name() instead.N)r)rrrrnamers r[r zScope.transactionsI$  n " ::$**;;5:DJJ - - 2<:rZc||_|jrN|jjr8||jj_|r||jj_|r||j d<yy)z?Set the transaction name and optionally the transaction source.sourceN)rrrr"r$r)rar"r$s r[set_transaction_namezScope.set_transaction_name2s^! ::$**;;59DJJ - - 2;A 118 /5D " "8 , rZc^tjdtd|j|y)zPWhen set a specific user is bound to the scope. Deprecated in favor of set_user.zEThe `Scope.user` setter is deprecated in favor of `Scope.set_user()`.r r N)r rrset_userrs r[userz Scope.user?s'  S  erZcp||_|jj}||j|yy)zSets a user for the scope.N)r()rrfrupdate)rarsessions r[r'zScope.set_userJs8 **,55   NNN & rZc|jS)z,Get/set current tracing span or transaction.)rrs r[rz Scope.spanRszzrZc||_t|trG|}|jr8|j|_|j r|j |j d<yyyy)Nr$)r isinstancer!r"rr$r)rarr s r[rz Scope.spanXsa  dK (K$/$4$4!%%7B7I7ID**84&  )rZc|jSr_rrs r[profilez Scope.profilees}}rZc||_yr_r0)rar1s r[r1z Scope.profilejs   rZc"||j|<y)z Sets a tag for a key to a specific value. :param key: Key of the tag to set. :param value: Value of the tag to set. N)rrakeyrs r[set_tagz Scope.set_tagps  3rZc:|jj|y)aSets multiple tags at once. This method updates multiple tags at once. The tags are passed as a dictionary or other mapping type. Calling this method is equivalent to calling `set_tag` on each key-value pair in the mapping. If a tag key already exists in the scope, its value will be updated. If the tag key does not exist in the scope, the key-value pair will be added to the scope. This method only modifies tag keys in the `tags` mapping passed to the method. `scope.set_tags({})` is, therefore, a no-op. :param tags: A mapping of tag keys to tag values to set. N)rr*)ratagss r[set_tagszScope.set_tags{s" $rZc<|jj|dy)zX Removes a specific tag. :param key: Key of the tag to remove. N)rrnrar5s r[ remove_tagzScope.remove_tags sD!rZc"||j|<y)zG Binds a context at a certain key to a specific value. N)rr4s r[ set_contextzScope.set_contexts$srZc<|jj|dy)zRemoves a context.N)rrnr;s r[remove_contextzScope.remove_contexts 3%rZc"||j|<y)z&Sets an extra key to a specific value.N)rr4s r[ set_extrazScope.set_extras" SrZc<|jj|dy)zRemoves a specific extra key.N)rrnr;s r[ remove_extrazScope.remove_extras d#rZc0t|_d|_y)zClears breadcrumb buffer.rN)rrrrs r[rzScope.clear_breadcrumbss"G()%rZc V|jjt|||||y)zAdds an attachment to future events sent from this scope. The parameters are the same as for the :py:class:`sentry_sdk.attachments.Attachment` constructor. )bytespathfilename content_typeadd_to_transactionsN)rrgr)rarGrIrHrJrKs r[add_attachmentzScope.add_attachments/   !)$7   rZc *|j}|jstjdy|jj d}|jj dt }t|xsd}|j||syt|xsd}|j d&tjtj|d<|j dd|d<| |||}n|}||jj|ntjd |t|j|kDrI|jj!|xj"d z c_t|j|kDrHyy) a Adds a breadcrumb. :param crumb: Dictionary with the data as the sentry v7/v8 protocol expects. :param hint: An optional value that can be used by `before_breadcrumb` to customize the breadcrumbs that are emitted. z*Dropped breadcrumb because no client boundNbefore_breadcrumbmax_breadcrumbsrY timestamptyperJz)before breadcrumb dropped breadcrumb (%s))rrr)inforrrdictr*rnowr utcrrglenpopleftr)racrumbhintrrrNrO new_crumbs r[add_breadcrumbzScope.add_breadcrumbsQ"! KKD E "NN../BC ..,,->@WXU[b! V DJB 99[ ! )!)hll!;E+  99V  $%E&M  ()%6II     $ $Y / KKCU K$##$6    % % '  ) )Q . )$##$6rZc |jd||j}|jd}||k7r tSt |xsi}|}| t d i|}|j |jd}|j||j||jp|j} | r&| j} | t|j| d<|jr,t|j|jjd<|j rt#|j |j$} | j|| |_t)|_|j*|j-t/|jdj1dxsd} |j3| |S) a Start and return a transaction. Start an existing transaction if given, otherwise create and start a new transaction with kwargs. This is the entry point to manual tracing instrumentation. A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a new child span within the transaction or any span, call the respective `.start_child()` method. Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded. When used as context managers, spans and transactions are automatically finished at the end of the `with` block. If not using context managers, call the `.finish()` method. When the transaction is finished, it will be sent to Sentry with all its finished child spans. :param transaction: The transaction to start. If omitted, we create and start a new transaction. :param instrumenter: This parameter is meant for internal use only. It will be removed in the next major version. :param custom_sampling_context: The transaction's custom sampling context. :param kwargs: Optional keyword arguments to be passed to the Transaction constructor. See :py:class:`sentry_sdk.tracing.Transaction` for available arguments. scope instrumenter)transaction_contextparent_sampled)sampling_context sample_rate _experiments max_spansi)maxlenrY) setdefaultrrrrr!to_jsonrar*_set_initial_sampling_decisionrcrrstr_baggage sentry_itemssampledr_start_timestamp_monotonic_nsrr_continuous_profileset_profiler_idrrinit_span_recorder) rar r_custom_sampling_contextrrconfiguration_instrumentertransaction_kwargsrbrrr1res r[start_transactionzScope.start_transactionsN '4("%+^^N%C" 5 5: )+"9"?R$  %;(:;K $/#6#6#8)88   7822DT2U  " " ."&"E"E"G ")BB?),[-D-D)EC &##CF++D $$11-@   ##[%N%NG  2 2DT 2 U#*K .O.QK + ..:++O,=> 7;;KHQTI  * *) * <rZc |jdtjdtdt 5|j d||j }|jd}||k7rtcdddS|jxs|jj}|1d|vr!|j}||j|d<td i|}n|jd i|}|cdddS#1swYyxYw) aO Start a span whose parent is the currently active span or transaction, if any. The return value is a :py:class:`sentry_sdk.tracing.Span` instance, typically used as a context manager to start and stop timing in a `with` block. Only spans contained in a transaction are sent to Sentry. Most integrations start a transaction at the appropriate time, for example for every incoming HTTP request. Use :py:meth:`sentry_sdk.start_transaction` to start a new transaction when one is not already in progress. For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Span`. The instrumenter parameter is deprecated for user code, and it will be removed in the next major version. Going forward, it should only be used by the SDK itself. descriptionNzEThe `description` parameter is deprecated. Please use `name` instead.r r r^r_rrY)rr rr new_scopergrrrrrfrrr start_child)rar_rrrsrrs r[ start_spanzScope.start_spanms* ::m $ 0 MMW"  [   gt ,__&F)/)G &99z[99? 8 8 : ? ?D|V+*.*M*M*O'*6-@-I-Iz*~f~(t''1&13[[sAC:A.C::Dc|j|tjt|jj }t jt||||||}|S)ze Sets the propagation context from environment or headers and returns a transaction. ) _sample_randoporiginr"r$) rtypingcastrrr|r!continue_from_headersr)raenviron_or_headersr}r"r$r~ sample_randr s r[continue_tracezScope.continue_tracesj ))*<=kk  9 9 ,. "77 #$6 7$  rZc tjdry|j||}|jj |||}|)|jddk7r||j _|S)a} Captures an event. Merges given scope data and calls :py:meth:`sentry_sdk.client._Client.capture_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. The `scope` and `scope_kwargs` parameters are mutually exclusive. :param scope_kwargs: Optional data to apply to event. For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`. The `scope` and `scope_kwargs` parameters are mutually exclusive. :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`). FN)eventrZr^rQr )r&rrr capture_eventrfr)rarrZr^ scope_kwargsevent_ids r[rzScope.capture_eventsr( ! $ $U +""5,7??$22TQV2W  EIIf$5$F8@D $ $ & 5rZc jtjdry|d}||d}|j|fd|i|S)a Captures a message. :param message: The string to send as the message. :param level: If no level is provided, the default level is `info`. :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events. The `scope` and `scope_kwargs` parameters are mutually exclusive. :param scope_kwargs: Optional data to apply to event. For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`. The `scope` and `scope_kwargs` parameters are mutually exclusive. :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`). FNrS)messagerr^)r&rr)rarrr^rrs r[capture_messagezScope.capture_messagesM$ ! $ $U + =E  "t!!%EuE EErZc Htjdry| t|}ntj}t ||j j\}} |j|f||d|S#t$r ttjYywxYw)aCaptures an exception. :param error: An exception to capture. If `None`, `sys.exc_info()` will be used. :param scope: An optional :py:class:`sentry_sdk.Scope` to apply to events. The `scope` and `scope_kwargs` parameters are mutually exclusive. :param scope_kwargs: Optional data to apply to event. For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`. The `scope` and `scope_kwargs` parameters are mutually exclusive. :returns: An `event_id` if the SDK decided to send the event (see :py:meth:`sentry_sdk.client._Client.capture_event`). FN)client_options)rZr^) r&rr(sysexc_infor'rrr Exceptionr")raerrorr^rrrrZs r[capture_exceptionzScope.capture_exceptions ! $ $U +  *51H||~H* T__%6%>%> t 7%4%%eT$eT|T T 7 &s||~ 6 7s"A88&B! B!c|jdd}|j|j}t|jj d|jj d|j ||_y)zStarts a new session. session_mode applicationrelease environment)rrr(rN)rn end_sessionrrrrrr)rarrrrs r[ start_sessionzScope.start_session$sfzz.-@  "NN&&y1**=9%   rZc|j}d|_|0|j|jj|yy)z)Ends the current session if there is one.N)rclosercapture_session)rarrr+s r[rzScope.end_session3s=--   MMO OO  - -g 6 rZc2|jd|_y)zStops automatic session tracking. This temporarily session tracking for the current scope when called. To resume session tracking call `resume_auto_session_tracking`. FN)rr)rarrs r[stop_auto_session_trackingz Scope.stop_auto_session_tracking=s ,1)rZcd|_y)zResumes automatic session tracking for the current scope if disabled earlier. This requires that generally automatic session tracking is enabled. N)rrs r[resume_auto_session_trackingz"Scope.resume_auto_session_trackingGs -1)rZct|jdkDr/tjd|j|jdd=|jj |y)z}Register a scope local event processor on the scope. :param func: This function behaves like `before_send.` zLToo many event processors on scope! Clearing list to free up some memory: %rN)rWrr)rrg)rafuncs r[add_event_processorzScope.add_event_processorOsS t%% & + NN^&& &&q) %%d+rZcV| ||fd}|jj|y)aRegister a scope local error processor on the scope. :param func: A callback that works similar to an event processor but is invoked with the original exception info triple as second argument. :param cls: Optionally, only process exceptions of this type. Nc` t|d}|r ||S|S#t$rd}YwxYw)NrRF)r.r)rris_instcls_ real_funcs r[rz'Scope.add_error_processor..funcqsE$(!d;G$UH55 !$#G$s  --)rrg)rarrrrs @@r[add_error_processorzScope.add_error_processoras/ ?DI  %%d+rZc<|j|j|d<yy)NrrrarrZrs r[_apply_level_to_eventzScope._apply_level_to_event}s ;; "![[E'N #rZc|jdit|dts6|djdg|ddj|j t|dtsL|ddD]'}t|dt st |d|d<)|ddjdyy#t$r!}tjd|Yd}~yd}~wwxYw)N breadcrumbsvaluesrPc |dS)NrPrY)rYs r[z3Scope._apply_breadcrumbs_to_event..s eK&8rZ)r5zError when sorting breadcrumbs)r) rgr.r extendrrjr%sortrr)debug)rarrZrrYerrs r[_apply_breadcrumbs_to_eventz!Scope._apply_breadcrumbs_to_events +% .? - + +Hb 9 -  * 1 1$2C2C D eM2NC"=1(;E!% "4c:-DU;EW-Xk*<m$X.3384 D  LL9C H  s1B=,B== C'C""C'c`|jd|j|j|d<yyy)Nr()rrrs r[_apply_user_to_eventzScope._apply_user_to_events0 99V  $)? JJE&M*@ $rZc`|jd|j|j|d<yyy)Nr )rrrs r[ _apply_transaction_name_to_eventz&Scope._apply_transaction_name_to_event5 99] # +0A0A0M#'#4#4E- 1N +rZc`|jd|j|j|d<yyy)Ntransaction_info)rrrs r[ _apply_transaction_info_to_eventz&Scope._apply_transaction_info_to_events7 99' ( 0T5K5K5W(,(>(>E$ %6X 0rZc`|jd|j|j|d<yyy)Nr)rrrs r[_apply_fingerprint_to_eventz!Scope._apply_fingerprint_to_eventrrZct|jr,|jdij|jyy)Nextra)rrgr*rs r[_apply_extra_to_eventzScope._apply_extra_to_events- <<   Wb ) 0 0 > rZct|jr,|jdij|jyy)Nr8)rrgr*rs r[_apply_tags_to_eventzScope._apply_tags_to_events- ::   VR ( / / ; rZc|jr+|jdij|j|jdi}|jd|j |d<yy)Ncontextstrace)rrgr*rr)rarrZrrs r[_apply_contexts_to_eventzScope._apply_contexts_to_eventsc >>   Z , 3 3DNN C##J3 << ( $ 6 6 8HW  )rZc|jj}t|dkDr4|jdijdij d|iyy)Nrrflagsr)rrrWrgr*)rarrZrrs r[_apply_flags_to_eventzScope._apply_flags_to_eventsR   u:>   Z , 7 7 D K K5!  rZc2tjd||y)Nz%s (%s) dropped event)r)rS)racausers r[_dropz Scope._drops +R7rZc&|jd}|}t|jj|j j|j j}|D]#}|||}||j |dcS|}%|S)zX Runs the error processors on the event and returns the modified event. rzerror processor)rr rrrfrr)rarrZrerror_processorserror_processor new_events r[run_error_processorszScope.run_error_processorss 88J'  $%%'99((*<<&&(::   $4+E8< $::o7HII! $4 rZc|jd}|dk(}|stj}tj}ttt xrt j xsg|xr |j xsg|xr |j xsg}|D]8}|} t5|||} ddd| |j|dcS| }:|S#1swY%xYw)zX Runs the event processors on the event and returns the modified event. rQcheck_inNzevent processor) rrirr rurrr#r) rarrZr is_check_inrIrKevent_processorsevent_processorrs r[run_event_processorszScope.run_event_processorss YYv J& .224O*..0M$'A-"A"AGREO$E$EKA-"A"AGR   $4! 02 /t >!NNDM  % %(-(B(BD % >>!NNDM <<;;&u||4 !LL,,.DKKOODL$x.A/ rZc|||_|||_||jj|||jj|||j j||||_yy)zUpdate the scope's attributes.N)rrrr*rrr)rar(rextrasrr8rs r[rzScope.update_from_kwargsfsy  DK  DJ   LL   '   NN ! !( +   JJ  d #  " +D  #rZc d|jjdtt|d|jd|j d S)N)rrRhexidrrrs r[__repr__zScope.__repr__~s4 NN # # 4M JJ JJ   rZc|jE|jjdjdxst}t ||_|jS)Nrd max_flags)capacity)rrrrrr)rars r[rz Scope.flagssS ;; !)).9==kJ)( %i8DK{{rZ)NNr_)NNNNF)NNNmanual)NNNNNN)UrRrSrTr __slots__rcr classmethodrrrfrrrrrrrhrrrrrrrrrrrrrrrrrr setterr%r(r'rr1r6r9r<r>r@rBrDrrLr\rSENTRYrurzrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrYrZr[reres I<T,(T  ..  22  88 D#$#$J M2693 B"<.82 2< 3()T : "" 11";;0 6'  [[ J J ^^    &" $&"$* !  .+/^!(( $ fP'3&9&95pKS>@F> D  721,* ,8) .' 5 ? 5 ? < 9 ,<  22h,B` ,0 rZrec#Ktj}|j}tj |} | tj |y#t tf$r ttjYywxYw# tj |w#t tf$r ttjYwwxYwxYww)a .. versionadded:: 2.0.0 Context manager that forks the current scope and runs the wrapped code in it. After the wrapped code is executed, the original scope is restored. Example Usage: .. code-block:: python import sentry_sdk with sentry_sdk.new_scope() as scope: scope.set_tag("color", "green") sentry_sdk.capture_message("hello") # will include `color` tag. sentry_sdk.capture_message("hello, again") # will NOT include `color` tag. N) rerrhrrjreset LookupError ValueErrorr"rr)rKrxtokens r[rxrxs.++-M""$I   y )E7 7   'Z( 7 &s||~ 6 7 7   'Z( 7 &s||~ 6 7s^:CB AC,BCBC C B"!C",CCCCCc#jKtj|} | tj|y#ttf$r t t jYywxYw# tj|w#ttf$r t t jYwwxYwxYww)ag .. versionadded:: 2.0.0 Context manager that uses the given `scope` and runs the wrapped code in it. After the wrapped code is executed, the original scope is restored. Example Usage: Suppose the variable `scope` contains a `Scope` object, which is not currently the active scope. .. code-block:: python import sentry_sdk with sentry_sdk.use_scope(scope): scope.set_tag("color", "green") sentry_sdk.capture_message("hello") # will include `color` tag. sentry_sdk.capture_message("hello, again") # will NOT include `color` tag. N)rrjrrrr"rr)r^rs r[ use_scopers2   u %E7  7   'Z( 7 &s||~ 6 7 7   'Z( 7 &s||~ 6 7sZB3A&4B3,A# B3"A##B3&B0(A>=B0>,B-*B0,B--B00B3c#FKtj}|j}tj |}tj }|j}t j |} | tj| t j|y#ttf$r ttjYEwxYw#ttf$r ttjYywxYw# tj|n2#ttf$r ttjYnwxYw t j|w#ttf$r ttjYwwxYwxYww)am .. versionadded:: 2.0.0 Context manager that forks the current isolation scope and runs the wrapped code in it. The current scope is also forked to not bleed data into the existing current scope. After the wrapped code is executed, the original scopes are restored. Example Usage: .. code-block:: python import sentry_sdk with sentry_sdk.isolation_scope() as scope: scope.set_tag("color", "green") sentry_sdk.capture_message("hello") # will include `color` tag. sentry_sdk.capture_message("hello, again") # will NOT include `color` tag. N) rerrhrrjrfrirrrr"rr)rKforked_current_scope current_tokenrIrisolation_tokens r[rIrIsG0++-M(--/"&&';?O 7!! 7   / 7  " "? 3 Z( 7 &s||~ 6 7 Z( 7 &s||~ 6 7 7   /Z( 7 &s||~ 6 7 7  " "? 3Z( 7 &s||~ 6 7sA3F!6D ;B'C&F!',CF!CF!,DF!DF! F D#"F#,EFEFE,+F,,FFFFF!c#Ktj}|j}tj |}t j |} | tj | t j |y#ttf$r ttjYEwxYw#ttf$r ttjYywxYw# tj |n2#ttf$r ttjYnwxYw t j |w#ttf$r ttjYwwxYwxYww)al .. versionadded:: 2.0.0 Context manager that uses the given `isolation_scope` and runs the wrapped code in it. The current scope is also forked to not bleed data into the existing current scope. After the wrapped code is executed, the original scopes are restored. Example Usage: .. code-block:: python import sentry_sdk with sentry_sdk.isolation_scope() as scope: scope.set_tag("color", "green") sentry_sdk.capture_message("hello") # will include `color` tag. sentry_sdk.capture_message("hello, again") # will NOT include `color` tag. N) rerrhrrjrirrrr"rr)rIrKrrrs r[use_isolation_scopers)0++-M(--/"&&';E:?,D.+E:-D..E:2EE:,E74E:6E77E::E=cFtjjS)zr?r@rArBrC sentry_sdkrDrErFrHrrirrurzrMr]rwr}rrrrrerxrrIrrsentry_sdk.clientrrYrZr[rs %',-QQF =&     '  (   5#A A8CH-.A A />OT:$( ((,. * , -  SSl."7"7J"7"7J-7-7`+7+7\81rZ