U 췀g@sddlZddlZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z ddl m Z ddlmZdd lmZdd lmZmZmZdd lmZmZdd lmZdd lmZddlmZddlm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4e4rNddl5m6Z6m7Z7ddl3m8Z8ddl3m9Z9ddl3m:Z:ddl3m;Z;ddl3mZ>ddl3m?Z?ddl3m@Z@ddl3mAZAddl3mBZBddl3mCZCdd lDmEZEdd!lFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPdd"l$mQZQddlRZRe@d#ZSeBd$ZTeBd%e9d&e8fd'ZUeBd(ZVdaWe-d)dd*ZXe-d+dd*ZYgZZGd,d-d-e Z[Gd.d/d/Z\d0d1Z]d2d3Z^d4d5Z_Gd6d7d7Z`ed8d9Zaed:d;ZbedZdd?d@ZeddAlfmgZge4rddlfZRdS)BNcopy)deque)contextmanager)Enum)datetimetimezonewraps)chain) Attachment)DEFAULT_MAX_BREADCRUMBS FALSE_VALUES INSTRUMENTER) FlagBufferDEFAULT_FLAG_CAPACITY)!try_autostart_continuous_profiler)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)MappingMutableMapping)Any)Callable)Deque)Dict) Generator)Iterator)List)Optional) ParamSpec)Tuple)TypeVar)Union)Unpack) BreadcrumbBreadcrumbHintErrorProcessorEventEventProcessorExcInfoHint LogLevelStrSamplingContextType)TransactionKwargsPRF.)boundTisolation_scope)default current_scopec@seZdZdZdZdZdZdS) ScopeTypecurrentZ isolationglobalZmergedN)__name__ __module__ __qualname__CURRENT ISOLATIONGLOBALMERGEDrSrS>/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/scope.pyrIisrIc@s&eZdZdddZddZddZdS) _ScopeManagerNcCs g|_dSN) _old_scopes)selfZhubrSrSrT__init__qsz_ScopeManager.__init__cCs*t}|j||}t||SrV)Scopeget_isolation_scoperWappendfork_isolation_scopeset)rXrF forked_scoperSrSrT __enter__us   z_ScopeManager.__enter__cCs|j}t|dSrV)rWpopr^r_)rXexc_type exc_valuetbZ old_scoperSrSrT__exit__s z_ScopeManager.__exit__)N)rLrMrNrYrarfrSrSrSrTrUps  rUcCst|dSrV)global_event_processorsr\) processorrSrSrTadd_global_event_processorsricCst||jdS)N)fsetdoc)property__doc__fnrSrSrT _attr_settersrpcstfdd}|S)Ncs2|js dSzd|_|f||WSd|_XdS)NTF)_should_capturerXargskwargsrnrSrTwrappers z!_disable_capture..wrapperr )rorurSrnrT_disable_captures rvc@seZdZdZdZdddZddZedd Zed d Z ed d Z eddZ eddZ eddZ dddZeddZdddZddZddZddZdd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zed4d5Zd6d7Z ed8d9Z!e"d:d;Z#e#j$dZ%ed?d@Z&dAdBZ'e"dCdDZ(e(j$dEdDZ(e"dFdGZ)e)j$dHdGZ)dIdJZ*dKdLZ+dMdNZ,dOdPZ-dQdRZ.dSdTZ/dUdVZ0dWdXZ1ddZd[Z2dd\d]Z3de4j5dfd^d_Z6e4j5fd`daZ7ddcddZ8ddedfZ9ddgdhZ:ddidjZ;dkdlZdqdrZ?dsdtZ@ddudvZAdwdxZBdydzZCd{d|ZDd}d~ZEddZFddZGddZHddZIddZJddZKddZLddZMeNdddZOddZPdddZQddZRe"ddZSdS)rZzaThe 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_event_processors_error_processorsrq_span_session _attachments_force_auto_session_tracking_profile_propagation_contextclient_type_last_event_id_flagsNcCsX||_g|_g|_d|_d|_t|_|dk r8|||| }|j |ddS)N) incoming_data) rrrrxrNonRecordingClientr set_clientclear_load_trace_data_from_envgenerate_propagation_context)rXtyrincoming_trace_informationrSrSrTrYs zScope.__init__cCst|j}|j|_|j|_|j|_|j|_|j|_|j|_t |j |_ |j |_ t |j |_ t |j |_ t |j|_t|j|_t|j|_t|j|_|j|_|j|_|j|_|j|_|j|_t|j|_|j|_|j|_t|j|_|S)zs Returns a copy of this scope. This also creates a copy of all referenced data structures. )object__new__ __class__rrrwrxryrzdictr{r|r}r~rrrlistrrrrqrrrrrrr)rXrvrSrSrT__copy__s2          zScope.__copy__cCs*t}|dkr&ttjd}t||S)zM .. versionadded:: 2.0.0 Returns the current scope. Nr)_current_scopegetrZrIrOr_)clsrHrSrSrTget_current_scopes   zScope.get_current_scopecCst|dS)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)rr_)rZnew_current_scoperSrSrTset_current_scopes zScope.set_current_scopecCs*t}|dkr&ttjd}t||S)zO .. versionadded:: 2.0.0 Returns the isolation scope. Nr)r^rrZrIrPr_)rrFrSrSrTr[s   zScope.get_isolation_scopecCst|dS)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)r^r_)rnew_isolation_scoperSrSrTset_isolation_scope,s zScope.set_isolation_scopecCstdkrttjdatS)zL .. versionadded:: 2.0.0 Returns the global scope. Nr) _global_scoperZrIrQrrSrSrTget_global_scope7s  zScope.get_global_scopecCs |jS)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. )r[rrrSrSrT last_event_idEszScope.last_event_idcCs|r|rtdtdk r ttnt}tj|_t}|dk rH| |t }|dk rb| |||kr|||kr|| ||dk rt |r||q| |n|r|j f||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 kwargsN) TypeErrorrrrZrIrRrr^rupdate_from_scopercallableupdate_from_kwargs)rXZadditional_scopeZadditional_scope_kwargsZ final_scoperFrHrSrSrT _merge_scopesVs&      zScope._merge_scopescCst}z |j}Wntk r*d}YnX|dk r@|r@|St}z |j}Wntk rjd}YnX|dk r|r|Sz tj}Wntk rd}YnX|dk r|r|StS)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_activer^rr)rrHrrFrSrSrT get_clientxs*       zScope.get_clientcCs|dk r |nt|_dS)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)rXrrSrSrTrs zScope.set_clientcCs t|}|S)zP .. versionadded:: 2.0.0 Returns a fork of this scope. r)rXr`rSrSrTr]sz Scope.forkcCspd}tjdpd}|tk}|rhi}tjdrHtjdpBd|t<tjdrhtjdpbd|t<|pndS)z Load Sentry trace id and baggage from environment variables. Can be disabled by setting SENTRY_USE_ENVIRONMENT to "false". NZSENTRY_USE_ENVIRONMENTZ SENTRY_TRACEZSENTRY_BAGGAGE)osenvironrlowerrrr)rXrZsentry_use_environmentZuse_environmentrSrSrTrs  zScope._load_trace_data_from_envcCs t|_dS)zt Creates a new propagation context and sets it as `_propagation_context`. Overwriting existing one. N)rrrXrSrSrTset_new_propagation_contextsz!Scope.set_new_propagation_contextcCs>|rt|}|dk r||_|jtjkr:|jdkr:|dS)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)rZfrom_incoming_datarrrIrOr)rXrpropagation_contextrSrSrTrs   z"Scope.generate_propagation_contextcCs2|jdkrdS|}|dk r*||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)rXbaggagerSrSrTget_dynamic_sampling_contexts z"Scope.get_dynamic_sampling_contextcOsT|}t|jr&|jdk r&|jS|jdk rHd|jj|jjf}|S| S)z Returns the Sentry "sentry-trace" header (aka the traceparent) from the currently active span or the scopes Propagation Context. Nz%s-%s) rroptionsspanZto_traceparentrtrace_idspan_idr[get_traceparent)rXrsrtr traceparentrSrSrTrs  zScope.get_traceparentcOs^|}t|jr&|jdk r&|jS|jdk rR|jj}|dkrJt|St|S| S)z Returns the Sentry "baggage" header containing trace information from the currently active span or the scopes Propagation Context. N) rrrrZ to_baggagerrrZ from_optionsr[r)rXrsrtrrrSrSrTrs   zScope.get_baggagecCs0|jdkrdS|jj|jj|jj|d}|S)zR Returns the Sentry "trace" context from the Propagation Context. N)rrparent_span_idr)rrrrr)rXZ trace_contextrSrSrTget_trace_context(s zScope.get_trace_contextcOsj|dd}|dk rtdd}|}|dk rB|dt|f7}|}|dk rf|dt|f7}|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)rbr%warningrrrr serialize)rXrsrtrmetaZ sentry_tracerrSrSrTtrace_propagation_meta9s& zScope.trace_propagation_metaccsN|jdk rJ|}|dk r$t|fV|}|dk rJt|}t|fVdS)zz Creates a generator which returns the `sentry-trace` and `baggage` headers from the Propagation Context. N)rrrrrrr)rXrZdscrrSrSrT iter_headersWs   zScope.iter_headerscos|}|jdsdS|dd}|p,|j}t|jrV|dk rV|D] }|VqHnn|jdk rv|D] }|VqhnN|}|jdk r|D] }|Vqn&| }|jdk r|D] }|VqdS)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. Zpropagate_tracesNr) rrrrbrrrrrr[)rXrsrtrrheaderrHrFrSrSrTiter_trace_propagation_headersfs&             z$Scope.iter_trace_propagation_headerscCsD|jdk r|jS|}|jdk r(|jS|}|jdk r@|jSdSrV)rrr[)rXrHrFrSrSrTget_active_propagation_contexts   z$Scope.get_active_propagation_contextcCsrd|_d|_d|_i|_d|_i|_i|_i|_g|_| d|_ d|_ d|_ d|_ d|_d|_d|_d|_dS)zClears the entire scope.NT)rwryrzr{r|r}r~rrclear_breadcrumbsrqrrrrrrrrrSrSrTrs$z Scope.clearcCstd||_dS)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%rrwrXvaluerSrSrTlevels z Scope.levelcCs ||_dS)zX Sets the level for the scope. :param value: The level to set. NrwrrSrSrT set_levelszScope.set_levelcCs ||_dS)z0When set this overrides the default fingerprint.N)ryrrSrSrT fingerprintszScope.fingerprintcCs&|jdkrdS|jjdkrdS|jjS)z8Return the transaction (root span) in the scope, if any.N)rcontaining_transactionrrSrSrT transactions   zScope.transactioncCs,td||_|jr(|jjr(||jj_dS)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%rrzrrnamerrSrSrTrs cCs>||_|jr,|jjr,||jj_|r,||jj_|r:||jd<dS)z?Set the transaction name and optionally the transaction source.sourceN)rzrrrrr{)rXrrrSrSrTset_transaction_names  zScope.set_transaction_namecCs||dS)zPWhen set a specific user is bound to the scope. Deprecated in favor of set_user.N)set_userrrSrSrTusersz Scope.usercCs(||_|j}|dk r$|j|ddS)zSets a user for the scope.N)r)r|r[rupdate)rXrsessionrSrSrTrs zScope.set_usercCs|jS)z,Get/set current tracing span or transaction.)rrrSrSrTrsz Scope.spancCs8||_t|tr4|}|jr4|j|_|jr4|j|jd<dS)Nr)r isinstancerrrzrr{)rXrrrSrSrTr#s cCs|jSrVrrrSrSrTprofile0sz Scope.profilecCs ||_dSrVr)rXrrSrSrTr5scCs||j|<dS)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)r}rXkeyrrSrSrTset_tag;s z Scope.set_tagcCs|j|dS)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)r}r)rXtagsrSrSrTset_tagsFszScope.set_tagscCs|j|ddS)zX Removes a specific tag. :param key: Key of the tag to remove. N)r}rbrXrrSrSrT remove_tagYszScope.remove_tagcCs||j|<dS)zG Binds a context at a certain key to a specific value. N)r~rrSrSrT set_contextbs zScope.set_contextcCs|j|ddS)zRemoves a context.N)r~rbrrSrSrTremove_contextmszScope.remove_contextcCs||j|<dS)z&Sets an extra key to a specific value.N)rrrSrSrT set_extratszScope.set_extracCs|j|ddS)zRemoves a specific extra key.N)rrbrrSrSrT remove_extra}szScope.remove_extracCs t|_dS)zClears breadcrumb buffer.N)rrrrSrSrTrszScope.clear_breadcrumbsFc Cs|jt|||||ddS)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)rr\r )rXrrrrrrSrSrTadd_attachments zScope.add_attachmentcKs|}|stddS|jd}|jdt}t|p@d}|||sVdSt|p^d}|ddkrt t j |d<|ddkrd|d<|dk r|||}n|}|dk r|j |n td |t|j |kr|j qdS) 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_breadcrumbsrS timestamptyperGz)before breadcrumb dropped breadcrumb (%s))rrr%inforrr rrrnowrutcrr\lenpopleft)rXcrumbhintrtrrrZ new_crumbrSrSrTadd_breadcrumbs.        zScope.add_breadcrumbc Ks|d||}|jd}||kr,tSt|p8i}|}|dkrPtf|}||jd}|||j |d|j rt |j |j } | j |d| |_ |jddpd} |j| d |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 instrumenterN)Ztransaction_contextparent_sampled)sampling_context _experiments max_spansi)maxlen) setdefaultrrrrrto_jsonrrZ_set_initial_sampling_decisionZsampledrZ_start_timestamp_monotonic_nsrrZinit_span_recorder) rXrrZcustom_sampling_contextrtrconfiguration_instrumenterZtransaction_kwargsrrrrSrSrTstart_transactions2'       zScope.start_transactionc Ks|ddk rtjdtddt|d||}|jd}||kr^tW5QRS|j pl| j }|dkrd|kr| }|dk r|j |d<t f|}n |jf|}|W5QRSQRXdS) 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.) stacklevelrrr)rwarningswarnDeprecationWarning new_scoperrrrrr[rrrZ start_child)rXrrtrrrrrSrSrT start_span s*     zScope.start_spanmanualcCs&||tjt|||||d}|S)ze Sets the propagation context from environment or headers and returns a transaction. )oporiginrr)rrZcontinue_from_headersr)rXZenviron_or_headersrrrrrrSrSrTcontinue_traceWs zScope.continue_tracecKsRtdrdS|||}|j|||d}|dk rN|ddkrN||_|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)eventrrrr)r"rrr capture_eventr[r)rXrrr scope_kwargsZevent_idrSrSrTrjs   zScope.capture_eventcKs:tdrdS|dkrd}||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`). FNr)messagerr)r"rr)rXrrrrrrSrSrTcapture_messages zScope.capture_messagecKs~tdrdS|dk r t|}nt}t||jd\}}z|j|f||d|WSt k rxt tYnXdS)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)Zclient_options)rr) r"rr$sysexc_infor#rrr Exceptionr)rXerrorrrrrrrSrSrTcapture_exceptions   zScope.capture_exceptioncOsD|dd}||}t|jd|jd|j|d|_dS)zStarts a new session. session_modeZ applicationrelease environment)rrrrN)rb end_sessionrrrrr|r)rXrsrtrrrSrSrT start_sessions   zScope.start_sessioncOs.|j}d|_|dk r*|||dS)z)Ends the current session if there is one.N)rcloserZcapture_session)rXrsrtrrSrSrTrs zScope.end_sessioncOs|d|_dS)zStops automatic session tracking. This temporarily session tracking for the current scope when called. To resume session tracking call `resume_auto_session_tracking`. FN)rrrrrSrSrTstop_auto_session_trackingsz Scope.stop_auto_session_trackingcCs d|_dS)zResumes automatic session tracking for the current scope if disabled earlier. This requires that generally automatic session tracking is enabled. N)rrrSrSrTresume_auto_session_trackingsz"Scope.resume_auto_session_trackingcCs8t|jdkr(td|j|jdd=|j|dS)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)rrr%rr\)rXfuncrSrSrTadd_event_processors zScope.add_event_processorcs.|dk r||fdd}|j|dS)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. Ncs>zt|d}Wntk r*d}YnX|r:||S|S)NF)rr)rrZis_instZcls_Z real_funcrSrTr%s  z'Scope.add_error_processor..func)rr\)rXr%rrSr(rTadd_error_processors  zScope.add_error_processorcCs|jdk r|j|d<dS)NrrrXrrrrSrSrT_apply_level_to_event#s zScope._apply_level_to_eventc Cs|didg|jzL|ddD]"}t|dtr*t|d|d<q*|ddjdddWn0tk r}ztj d|dW5d}~XYnXdS) NZ breadcrumbsvaluesrcSs|dS)NrrS)rrSrSrT4z3Scope._apply_breadcrumbs_to_event..)rzError when sorting breadcrumbs)r) rextendrrstrr!sortrr%debug)rXrrrrerrrSrSrT_apply_breadcrumbs_to_event(sz!Scope._apply_breadcrumbs_to_eventcCs&|ddkr"|jdk r"|j|d<dS)Nr)rr|r*rSrSrT_apply_user_to_event9szScope._apply_user_to_eventcCs&|ddkr"|jdk r"|j|d<dS)Nr)rrzr*rSrSrT _apply_transaction_name_to_event>sz&Scope._apply_transaction_name_to_eventcCs&|ddkr"|jdk r"|j|d<dS)NZtransaction_info)rr{r*rSrSrT _apply_transaction_info_to_eventCsz&Scope._apply_transaction_info_to_eventcCs&|ddkr"|jdk r"|j|d<dS)Nr)rryr*rSrSrT_apply_fingerprint_to_eventHsz!Scope._apply_fingerprint_to_eventcCs|jr|di|jdS)Nextra)rrrr*rSrSrT_apply_extra_to_eventMszScope._apply_extra_to_eventcCs|jr|di|jdS)Nr)r}rrr*rSrSrT_apply_tags_to_eventRszScope._apply_tags_to_eventcCsf|jr|di|j|di}|ddkrbt|rV|jdk rV|j|d<n ||d<dS)Ncontextstrace)r~rrrrrr)rXrrrr<rSrSrT_apply_contexts_to_eventWs zScope._apply_contexts_to_eventcCstd||dS)Nz%s (%s) dropped event)r%r)rXcauserrSrSrT_dropesz Scope._dropcCsd|d}|dk r`t|j|j|j}|D]*}|||}|dkrZ||dS|}q4|S)zX Runs the error processors on the event and returns the modified event. rNzerror processor)rr rrr[rr@)rXrrrZerror_processorsZerror_processor new_eventrSrSrTrun_error_processorsjs  zScope.run_error_processorsc Cs|d}|dk}|st}t}tttr4tjp6g|r@|jpBg|rL|jpNg}|D]@}|} t|||} W5QRX| dkr||dS| }qV|S)zX Runs the event processors on the event and returns the modified event. rcheck_inNzevent processor) rr^rr rgrrrr@) rXrrr is_check_inrFrHZevent_processorsZevent_processorrArSrSrTrun_event_processorss&    zScope.run_event_processorsc Cs2|d}|dk}|dk}|dp&g}|jD]}|r<|jr.||q.||d<|||||r~d|didii|d<|s||||||||||||| |||| |||| |||| ||||s|s| ||||||}|dkrdS|||}|dkr.dS|S)zBApplies the information contained on the scope to the given event.rrrC attachmentsr=r<N)rrrr\r>rr+r8r5r6r7r;r:r4rBrE) rXrrrrZis_transactionrDZattachments_to_send attachmentrSrSrTapply_to_events<        zScope.apply_to_eventcCs|jdk r|j|_|jdk r$|j|_|jdk r6|j|_|jdk rN|j|j|jdk r`|j|_|jrt|j|j|jr|j|j|jr|j|j|j r|j |j |j r|j |_ |j r|j |j |j r|j |_ |jr|j|_|jr|j|_dS)z+Update the scope with another scope's data.N)rwryrzr{rr|r}r~rrr/rrrrr)rXrrSrSrTrs8     zScope.update_from_scopecCsj|dk r||_|dk r||_|dk r0|j||dk rD|j||dk rX|j||dk rf||_dS)zUpdate the scope's attributes.N)rwr|rrr~r}ry)rXrrextrasr<rrrSrSrTrs    zScope.update_from_kwargscCs d|jjtt||j|jfS)Nz<%s id=%s name=%s type=%s>)rrLhexidrxrrrSrSrT__repr__ s  zScope.__repr__cCs4|jdkr.|jddp t}t|d|_|jS)Nr max_flags)capacity)rrrrrr)rXrMrSrSrTflagss   z Scope.flags)NN)NN)N)N)N)NNNNF)NN)NNNr)NN)NN)NN)N)N)NNNNNN)TrLrMrNrm __slots__rYr classmethodrrr[rrrrrrr]rrrrrrrrrrrrrprrrrlrsetterrrrrrrrrrrrrrrrrZSENTRYrr rrrrr rr"r#r&r)r+r4r5r6r7r8r:r;r>r@rBrErvrHrrrLrOrSrSrSrTrZs  (       " %   %                 . T8   "    3"  rZc cs6t}|}t|}z |VW5t|XdS)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)rZrr]rr_reset)rHr tokenrSrSrTr s   r c cs&t|}z |VW5t|XdS)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)rr_rS)rrTrSrSrT use_scopeBs  rUc csZt}|}t|}t}|}t|}z |VW5t|t|XdS)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)rZrr]rr_r[r^rS)rHforked_current_scope current_tokenrFrisolation_tokenrSrSrTrFes    c csJt}|}t|}t|}z |VW5t|t|XdS)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)rZrr]rr_r^rS)rFrHrVrWrXrSrSrTuse_isolation_scopes    rYcCs tS)zr?r@Z sentry_sdkrArBrCrErr^rrgrIrUrirprvrZr rUrFrYrZZsentry_sdk.clientrrSrSrSrTs          (              0     " " ) '