U 췀g",@s8ddlZddlZddlmZddlmZmZddlmZddl m Z ddl m Z m Z mZmZddlmZmZmZddlmZdd lmZertdd 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 dedefdZ3nddZddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dZ5d?d@Z6e5dAd'Z7dBd-Z8e5dCd(Z9e5dDd)Z:e5dEd*Z;e5dFd/Ze5dcdId!Z?e5dddJdZ@edKd#ZAedLd#ZAdedMd#ZAedNd1ZBedOd1ZBdfdPd1ZBe5dQd6ZCe5dRd7ZDe5dSd2ZEe5dTd3ZFe5dUd8ZGe5dVd4ZHe6dgdWd%ZIe5dXd9ZJe5de jKdfdYd:ZLdhd[d5ZMdid\d+ZNd]d,ZOd^d&ZPdjd`d$ZQdS)kN)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.)boundcCs|SN)xr*r*.inner)warningswarnDeprecationWarningr7Zgenerate_propagation_contextr)r[r`r*r_r,r1s cCsdSr)r*r*r*r*r,r=scCsdSr)r*rZr*r*r,r=sc Cs\tjdtdd|dk rVt,tdtt}||W5QRXW5QRXdStS)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)rarbrccatch_warnings simplefilterr=r)r[rRr*r*r,r=s   cCst||Sr))r7rBkeyvaluer*r*r,rB$scCs t|Sr))r7rC)tagsr*r*r,rC*scCst||Sr))r7r>rgr*r*r,r>0scCst||Sr))r7r?rgr*r*r,r?6scCs t|Sr))r7rDrir*r*r,rD<scCs t|Sr))r7r@rkr*r*r,r@BscCstj||dS)Ntimeoutr[)r5r3rlr*r*r,r3HscKstjf|Sr))r8rE)rYr*r*r,rEQscKstj|||f|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. )r8rF) transactionZ instrumenterZcustom_sampling_contextrYr*r*r,rFYs'cCs"tj}|dk r||||dSr))r8rnrA)nameriunitrnr*r*r,rAscCs t|S)zU Returns the currently active span if there is one running, otherwise `None` )rr9r_r*r*r,r9scCs tS)zP Returns the traceparent either from the active span or from the scope. )r8r:r*r*r*r,r:scCst}|dk r|SdS)zH Returns Baggage either from the active span or from the scope. N)r8r4 serialize)Zbaggager*r*r,r4s manualcCst|||||S)z] Sets the propagation context from environment or headers and returns a transaction. )r7r2)Zenviron_or_headersoprpsourceoriginr*r*r,r2s)NN)NN)NN)NN)N)N)NN)ro)N)NNNrs)RrIra contextlibrZ sentry_sdkrrZsentry_sdk._init_implementationrZsentry_sdk.constsrZsentry_sdk.scoperrr r Zsentry_sdk.tracingr r r Zsentry_sdk.cronsrtypingrcollections.abcrrrrrrrrrrtyping_extensionsrZsentry_sdk.clientrZsentry_sdk._typesrrrrr r!r"r#r$r%r&r'__all__rOrPr5r;r6r7r8r<r.r0r/r-r1r=rBrCr>r?rDr@r3rEZSENTRYrFrAr9r:r4r2r*r*r*r,s                 ( #              $            +