0i;ddlZddlZddlmZddlmZmZddlmZddl m Z ddl m Z m Z mZmZddlmZmZmZddlmZdd lmZer|dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddlm0Z0m1Z1e dZ2e dedefZ3ndZgdZ4dZ5dZ6e5d Z7d!Z8e5d"Z9e5d#Z:e5d$Z;e5d%Ze5 dCd(Z?e5 dDd)Z@e5 dCd*ZAed+ZBed,ZB dEd-ZBed.ZCed/ZC dEd0ZCe5d1ZDe5d2ZEe5d3ZFe5d4ZGe5d5ZHe5d6ZIe6 dCd7ZJe5d8ZKe5de jdfd9ZMdFd:ZNdEd;ZOd<ZPd=ZQ dGd>ZRe5 dHd?ZSe5d@ZTe5dEdAZUdIdBZVy)JN)contextmanager) tracing_utilsClient)init) INSTRUMENTER)Scope _ScopeManager new_scopeisolation_scope)NoOpSpan Transactiontrace)monitor) TYPE_CHECKING)Mapping)Any)Dict) Generator)Optional)overload)Callable)TypeVar)ContextManager)Union)Unpack) BaseClient)EventHint BreadcrumbBreadcrumbHintExcInfoMeasurementUnit LogLevelStrSamplingContext)SpanTransactionKwargsTF.)boundc|SN)xs =/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/api.pyrr.s)$radd_attachmentadd_breadcrumb capture_eventcapture_exceptioncapture_messageconfigure_scopecontinue_traceflush get_baggage get_clientget_global_scopeget_isolation_scopeget_current_scopeget_current_spanget_traceparentis_initializedr last_event_idr push_scope set_context set_extra set_levelset_measurementset_tagset_tagsset_user start_spanstart_transactionrr start_session end_sessionset_transaction_nameupdate_current_spancd|jzdtjtt|j|_|S)Nz(Alias for :py:meth:`sentry_sdk.Scope.%s` )__name__inspectgetdocgetattrr__doc__fs r. scopemethodrX\s7 3QZZ?wuajj12AI Hr/cd|jzdtjtt|j|_|S)Nz)Alias for :py:meth:`sentry_sdk.Client.%s`rP)rQrRrSrTrrUrVs r. clientmethodrZes7 4ajj@wvqzz23AI Hr/c*tjSr+)rr9r,r/r.r9r9ns    r/c2tjS)z .. versionadded:: 2.0.0 Returns whether Sentry has been initialized or not. If a client is available and the client is active (meaning it is configured to send data) then Sentry is initialized. )r9 is_activer,r/r.r?r?ts < ! ! ##r/c*tjSr+)rr:r,r/r.r:r:s  ! ! ##r/c*tjSr+)rr;r,r/r.r;r;s  $ $ &&r/c*tjSr+)rr<r,r/r.r<r<s  " " $$r/c*tjS)zn See :py:meth:`sentry_sdk.Scope.last_event_id` documentation regarding this method's limitations. )rr@r,r/r.r@r@s     r/c >tj||fd|i|SNscope)r<r2)eventhintrd scope_kwargss r.r2r2s' -   , ,UD V V VVr/c >tj||fd|i|Src)r<r4)messagelevelrdrgs r.r4r4s2 /   . . # '3 r/c <tj|fd|i|Src)r<r3)errorrdrgs r.r3r3s% 1   0 0 Te T| TTr/c<tj|||||Sr+)r;r0)bytesfilenamepath content_typeadd_to_transactionss r.r0r0s&  / / x|-@ r/c :tj||fi|Sr+)r;r1)crumbrfkwargss r.r1r1s" 0  / /t Fv FFr/cyr+r,r,r/r.r5r5 r/cyr+r,callbacks r.r5r5  r/ctjdtdtj | |yt fd}|S)z Reconfigures the scope. :param callback: If provided, call the callback with the current scope. :returns: If no callback is provided, returns a context manager that returns the scope. zsentry_sdk.configure_scope is deprecated and will be removed in the next major version. Please consult our migration guide to learn how to migrate to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-configuring stacklevelNc3Kywr+r,rdsr.innerzconfigure_scope..inners s )warningswarnDeprecationWarningr;generate_propagation_contextr)rzrrds @r.r5r5s` MM Y   !E &&( 7Nr/cyr+r,r,r/r.rArA rwr/cyr+r,rys r.rArAr{r/c(tjdtd|Stj5tjdtt 5}||ddddddyt S#1swYxYw#1swYyxYw)a Pushes a new layer on the scope stack. :param callback: If provided, this method pushes a scope, calls `callback`, and pops the scope again. :returns: If no `callback` is provided, a context manager that should be used to pop the scope again. zsentry_sdk.push_scope is deprecated and will be removed in the next major version. Please consult our migration guide to learn how to migrate to the new API: https://docs.sentry.io/platforms/python/migration/1.x-to-2.x#scope-pushingr}r~Nignore)rrrcatch_warnings simplefilterrAr )rzrds r.rArAs{ MM U    $ $ &  ! !(,> ?' ? 's#%B A<!B<B BBc6tj||Sr+)r;rFkeyvalues r.rFrF7s  ( (e 44r/c4tj|Sr+)r;rG)tagss r.rGrG=s  ) )$ //r/c6tj||Sr+)r;rBrs r.rBrBCs  , ,S% 88r/c6tj||Sr+)r;rCrs r.rCrCIs  * *3 66r/c4tj|Sr+)r;rHrs r.rHrHOs  ) )% 00r/c4tj|Sr+)r;rDrs r.rDrDUs  * *5 11r/c8tj||S)Ntimeoutrz)r9r7rs r.r7r7[s <  g  AAr/c 6tjdi|S)Nr,)r<rI)rus r.rIrIds *   ) ) 3F 33r/c <tj|||fi|S)aV Start and return a transaction on the current scope. 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. )r<rJ) transaction instrumentercustom_sampling_contextrus r.rJrJls.N 1   0 0\#: >D r/cXtj}||j|||yy)zs .. deprecated:: 2.28.0 This function is deprecated and will be removed in the next major release. N)r<rrE)namerunitrs r.rErEs/ $%11K##D%6r/c,tj|S)zU Returns the currently active span if there is one running, otherwise `None` )rr=rs r.r=r=s  ) )% 00r/c2tjS)zP Returns the traceparent either from the active span or from the scope. )r<r>r,r/r.r>r>s   . . 00r/cXtj}||jSy)zH Returns Baggage either from the active span or from the scope. N)r<r8 serialize)baggages r.r8r8s-  !--/G  "" r/c<tj|||||S)z] Sets the propagation context from environment or headers and returns a transaction. )r;r6)environ_or_headersoprsourceorigins r.r6r6s%  / /Bff r/c6tj|S)N session_mode)r;rKrs r.rKrKs  . .L . IIr/c2tjSr+)r;rLr,r/r.rLrLs  , , ..r/c6tj||Sr+)r<rM)rrs r.rMrMs   3 3D& AAr/ct}|y|||_|||_| | td|t j dt d|}||j|yy)a Update the current active span with the provided parameters. This function allows you to modify properties of the currently active span. If no span is currently active, this function will do nothing. :param op: The operation name for the span. This is a high-level description of what the span represents (e.g., "http.client", "db.query"). You can use predefined constants from :py:class:`sentry_sdk.consts.OP` or provide your own string. If not provided, the span's operation will remain unchanged. :type op: str or None :param name: The human-readable name/description for the span. This provides more specific details about what the span represents (e.g., "GET /api/users", "SELECT * FROM users"). If not provided, the span's name will remain unchanged. :type name: str or None :param data: A dictionary of key-value pairs to add as data to the span. This data will be merged with any existing span data. If not provided, no data will be added. .. deprecated:: 2.35.0 Use ``attributes`` instead. The ``data`` parameter will be removed in a future version. :type data: dict[str, Union[str, int, float, bool]] or None :param attributes: A dictionary of key-value pairs to add as attributes to the span. Attribute values must be strings, integers, floats, or booleans. These attributes will be merged with any existing span data. If not provided, no attributes will be added. :type attributes: dict[str, Union[str, int, float, bool]] or None :returns: None .. versionadded:: 2.35.0 Example:: import sentry_sdk from sentry_sdk.consts import OP sentry_sdk.update_current_span( op=OP.FUNCTION, name="process_user_data", attributes={"user_id": 123, "batch_size": 50} ) NzJCannot provide both `data` and `attributes`. Please use only `attributes`.zDThe `data` parameter is deprecated. Please use `attributes` instead.r}r~)r=r description ValueErrorrrr update_data)rr attributesdata current_spans r.rNrNsd$%L ~  #'   J2 X    R     ,r/)NN)NNNNFr+))NNNmanual) application)NNNN)WrRr contextlibr sentry_sdkrrsentry_sdk._init_implementationrsentry_sdk.constsrsentry_sdk.scoperr r r sentry_sdk.tracingr r rsentry_sdk.cronsrtypingrcollections.abcrrrrrrrrrrtyping_extensionsrsentry_sdk.clientrsentry_sdk._typesrrrr r!r"r#r$r%r&r'r(__all__rXrZr9r?r:r;r<r@r2r4r3r0r1r5rArFrGrBrCrHrDr7rISENTRYrJrEr=r>r8r6rKrLrMrNr,r/r.rs1%,0*MM;;$ ' %(,   ; A8CH-.A % P     $ $ $  ' '  % %  ! !   W W        U U        G G        !H        > 5 5  0 0  9 9  7 7  1 1  2 2   BB 4 4 $$ ( (V711 AI  J J / /  B B L-r/