
    gh              
       X   S SK Jr  S SKrS SKrS SKJrJrJr  S SKJr  S SK	r	S SK
JrJrJrJr  S SKJr  S SKJrJrJrJrJr  S SKJr  \(       a  S S	KJrJrJr  S S
KJr  S SKJr  S SKJr  S SKJ r   S SKJ!r!  S SKJ"r"  S SKJ#r#  S SKJ$r$  S SKJ%r%  S SKJ&r&  S SK'J(r(J)r)  \#" S5      r*\&" S5      r+S SKJ,r,  S SK-J.r.  S SK/J0r0J1r1J2r2J3r3   " S S\(SS9r4 " S S\4SS9r5\(" S S!\605      r7S"r8S#r9 " S$ S%\6\5      r:\:Rv                  /r<\:Rz                  \:Rz                  \:Rz                  \:R|                  \:Rv                  \:Rz                  \:R|                  \:R|                  \:R|                  S&.	r?S' r@ " S( S)5      rA " S* S+5      rB " S, S-\B5      rC " S. S/\B5      rD\(       a$  \" S7SSS\R                  S0.S1 jj5       rF\"S2 5       rF S7SSS\R                  S0.S3 jjrFS S4KGJHrHJIrIJJrJJKrKJLrLJMrM  \R                  " 5          \R                  " S5\P5        S S6KQJRrR  SSS5        g! , (       d  f       g= f)8    )DecimalN)datetime	timedeltatimezone)Enum)INSTRUMENTER
SPANSTATUSSPANDATASPANTEMPLATE)get_profiler_id)get_current_thread_metais_valid_sample_rateloggernanosecond_timeshould_be_treated_as_error)TYPE_CHECKING)CallableMappingMutableMapping)Any)Dict)Iterator)List)Optional)overload)	ParamSpec)Tuple)Union)TypeVar)	TypedDictUnpackPR)ContinuousProfile)Profile)EventMeasurementUnitSamplingContextMeasurementValuec                       \ rS rSr% \\S'    \\S'    \\S'    \\S'    \\S'    \\S'    \\S'    \S	   \S
'    \\S'    \S   \S'    \\\	\
4      \S'    S\S'    \\S'    \\S'   Srg)
SpanKwargs0   trace_idspan_idparent_span_idsame_process_as_parentsampledopdescriptionzsentry_sdk.HubhubstatusTransactioncontaining_transactionstart_timestampzsentry_sdk.Scopescopeoriginname N)__name__
__module____qualname____firstlineno__str__annotations__boolr   r   r   float__static_attributes__r<       U/home/kali/devsecops-assessor/venv/lib/python3.13/site-packages/sentry_sdk/tracing.pyr+   r+   0   s    	
 T< $$J	
 	
  	Y&''sr ( 778!%%"899	
 "!X	 	`rF   r+   F)totalc                   8    \ rS rSr% \\S'    \\S'    S\S'   Srg)TransactionKwargsk   sourceparent_sampledBaggagebaggager<   N)r=   r>   r?   r@   rA   rB   rC   rE   r<   rF   rG   rJ   rJ   k   s     	 PrF   rJ   ProfileContextprofiler_idrO   zsentry-tracec                   2    \ rS rSrSrSrSrSrSrSr	S r
S	rg
)TransactionSource   	componentcustomroutetaskurlviewc                     U R                   $ N)valueselfs    rG   __str__TransactionSource.__str__   s    zzrF   r<   N)r=   r>   r?   r@   	COMPONENTCUSTOMROUTETASKURLVIEWr`   rE   r<   rF   rG   rS   rS      s%    IFED
CDrF   rS   )	endpointfunction_namehandler_namemethod_and_path_patternpath
route_nameroute_patternuri_templaterY   c                 x   U S:  a  [         R                  $ SU s=::  a  S:  a  O  OU S:X  a  [         R                  $ U S:X  a  [         R                  $ U S:X  a  [         R                  $ U S:X  a  [         R
                  $ U S:X  a  [         R                  $ U S:X  a  [         R                  $ [         R                  $ SU s=::  a  S	:  ad  O  [         R                  $ U S
:X  a  [         R                  $ U S:X  a  [         R                  $ U S:X  a  [         R                  $ [         R                  $ [         R                  $ )z
Returns the Sentry status corresponding to the given HTTP status code.

See: https://develop.sentry.dev/sdk/event-payloads/contexts/#trace-context
i  i  i  i  i  i  i  i  iX  i  i  i  )r	   OKPERMISSION_DENIED	NOT_FOUNDRESOURCE_EXHAUSTEDFAILED_PRECONDITIONUNAUTHENTICATEDALREADY_EXISTSINVALID_ARGUMENTDEADLINE_EXCEEDEDUNIMPLEMENTEDUNAVAILABLEINTERNAL_ERRORUNKNOWN_ERROR)http_status_codes    rG   get_span_status_from_http_coder      s    #}}	 	&3	&s"///$'''$000$111$---$,,,...	 	&3	& ### s"///$+++$))),,,###rF   c                   (    \ rS rSrSrSrS rS rSrg)_SpanRecorder   z5Limits the number of spans recorded in a transaction.maxlenspansdropped_spansc                 4    US-
  U l         / U l        SU l        g )N   r   r   r_   r   s     rG   __init___SpanRecorder.__init__   s     qj
rF   c                     [        U R                  5      U R                  :  a  S Ul        U =R                  S-  sl        g U R                  R                  U5        g )Nr   )lenr   r   _span_recorderr   append)r_   spans     rG   add_SpanRecorder.add   sA    tzz?T[[("&D!#JJd#rF   )r   r   r   N)	r=   r>   r?   r@   __doc__	__slots__r   r   rE   r<   rF   rG   r   r      s    ?4I	$rF   r   c                      \ rS rSrSrSr              S(S jrS r\S 5       r	\	R                  S 5       r	\S	 5       r\R                  S
 5       rS rS rS rS r\S 5       r\R$                  4S jr\S 5       r\SS.S j5       rS r\S 5       rS rS rS rS rS rS rS rS)S jr S r!S r"S  r#S! r$S*S" jr%S# r&S$ r'S% r(S& r)S'r*g)+Span   a  A span holds timing information of a block of code.
Spans can have multiple child spans thus forming a span tree.

:param trace_id: The trace ID of the root span. If this new span is to be the root span,
    omit this parameter, and a new trace ID will be generated.
:param span_id: The span ID of this span. If omitted, a new span ID will be generated.
:param parent_span_id: The span ID of the parent span, if applicable.
:param same_process_as_parent: Whether this span is in the same process as the parent span.
:param sampled: Whether the span should be sampled. Overrides the default sampling decision
    for this span when provided.
:param op: The span's operation. A list of recommended values is available here:
    https://develop.sentry.dev/sdk/performance/span-operations/
:param description: A description of what operation is being performed within the span.

    .. deprecated:: 2.15.0
        Please use the `name` parameter, instead.
:param name: A string describing what operation is being performed within the span.
:param hub: The hub to use for this span.

    .. deprecated:: 2.0.0
        Please use the `scope` parameter, instead.
:param status: The span's status. Possible values are listed at
    https://develop.sentry.dev/sdk/event-payloads/span/
:param containing_transaction: The transaction that this span belongs to.
:param start_timestamp: The timestamp when the span started. If omitted, the current time
    will be used.
:param scope: The scope to use for this span. If not provided, we use the current scope.
)	_trace_id_span_idr/   r0   r1   r2   r3   _measurementsr8   _start_timestamp_monotonic_nsr5   	timestamp_tags_datar   r4   _context_manager_state_containing_transaction_local_aggregatorr9   r:   r;   _flags_flags_capacityNc                    Xl         X l        X0l        X@l        XPl        X`l        U=(       d    UU l        Xl        Xl        Xl	        Xl
        0 U l        0 U l        0 U l        Xl        0 U l        SU l        Ub>  ["        R$                  " S[&        SS9  U R                  =(       d    UR                  U l	        Uc%  [(        R*                  " [,        R.                  5      nO:[1        U[2        5      (       a%  [(        R4                  " U[,        R.                  5      nXl         [9        5       U l        S U l        S U l         S U l!        U RE                  5         U RG                  [I        5       5        g ! [<         a     NKf = f)N
   z>The `hub` parameter is deprecated. Please use `scope` instead.   
stacklevel)%r   r   r/   r0   r1   r2   r3   r5   r4   r9   r:   r   r   r   r   r   r   warningswarnDeprecationWarningr   nowr   utc
isinstancerD   fromtimestampr8   r   r   AttributeErrorr   r   r   update_active_threadset_profiler_idr   )r_   r-   r.   r/   r0   r1   r2   r3   r4   r5   r7   r8   r9   r:   r;   s                  rG   r   Span.__init__  s>   $ ",&<#.;


'=$!?MMP" 0syyDJ"&ll8<<8O//&44_hllSO.	 2A1BD.
 "!%!!#_./  		s    E. .
E;:E;c                 @    U R                   c  [        U5      U l         g g r\   )r   r   r   s     rG   init_span_recorderSpan.init_span_recorderb  s     &"/"7D 'rF   c                     U R                   (       d$  [        R                  " 5       R                  U l         U R                   $ r\   )r   uuiduuid4hexr^   s    rG   r-   Span.trace_idg  s(     ~~!ZZ\--DN~~rF   c                     Xl         g r\   )r   r_   r]   s     rG   r-   r   o  s	     rF   c                     U R                   (       d'  [        R                  " 5       R                  SS  U l         U R                   $ )N   )r   r   r   r   r^   s    rG   r.   Span.span_idt  s/     }} JJL,,RS1DM}}rF   c                     Xl         g r\   )r   r   s     rG   r.   r   |  s	     rF   c                 D    U R                   nUc  [        5       =ol         U$ r\   )r   LocalAggregator)r_   rvs     rG   _get_local_aggregatorSpan._get_local_aggregator  s%    ##:*9*;;B'	rF   c                     SU R                   R                  < SU R                  < SU R                  < SU R                  < SU R
                  < SU R                  < SU R                  < SU R                  < S	3$ )
N<z(op=z, description:, trace_id=
, span_id=, parent_span_id=
, sampled=	, origin=)>)		__class__r=   r2   r3   r-   r.   r/   r1   r:   r^   s    rG   __repr__Span.__repr__  sP    
 ''  ##
	
rF   c                     U R                   =(       d    [        R                  " 5       nUR                  nXl        X4U l        U $ r\   )r9   
sentry_sdkget_current_scoper   r   )r_   r9   old_spans      rG   	__enter__Span.__enter__  s7    

<j::<::
',&7#rF   c                     Ub/  [        X5      (       a  U R                  [        R                  5        U R                  u  pEU ?U R                  U5        XTl        g r\   )r   
set_statusr	   r|   r   finishr   )r_   tyr]   tbr9   r   s         rG   __exit__Span.__exit__  sI    !;B!F!FOOJ55655'E
rF   c                     U R                   $ )zThe ``Transaction`` that this span belongs to.
The ``Transaction`` is the root of the span tree,
so one could also think of this ``Transaction`` as the "root span".)r   r^   s    rG   r7   Span.containing_transaction  s     +++rF   c                    UR                  S5      b  [        R                  " S[        SS9  [        R
                  " 5       R                  S   nX:w  a
  [        5       $ UR                  SU R                  5        [        SU R                  U R                  U R                  S.UD6nU R                  =(       a    U R                  R                  nU(       a  UR                  U5        U$ )	a  
Start a sub-span from the current span or transaction.

Takes the same arguments as the initializer of :py:class:`Span`. The
trace id, sampling decision, transaction pointer, and span recorder are
inherited from the current span/transaction.

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.
r3   zEThe `description` parameter is deprecated. Please use `name` instead.r   r   instrumenterr1   )r-   r/   r7   r<   )getr   r   r   r   
get_clientoptionsNoOpSpan
setdefaultr1   r   r-   r.   r7   r   r   )r_   r   kwargsconfiguration_instrumenterchildspan_recorders         rG   start_childSpan.start_child  s     ::m$0MMW" &0%:%:%<%D%D^%T"5:)T\\2 
]]<<#'#>#>
 	
 ''VD,G,G,V,V 	 e$rF   c                     U [         L a  [        R                  " S5        [        R                  " [        U5      40 UD6$ )a  
Create a Transaction with the given params, then add in data pulled from
the ``sentry-trace`` and ``baggage`` headers from the environ (if any)
before returning the Transaction.

This is different from :py:meth:`~sentry_sdk.tracing.Span.continue_from_headers`
in that it assumes header names in the form ``HTTP_HEADER_NAME`` -
such as you would get from a WSGI/ASGI environ -
rather than the form ``header-name``.

:param environ: The ASGI/WSGI environ to pull information from.
zXDeprecated: use Transaction.continue_from_environ instead of Span.continue_from_environ.)r   r   warningr6   continue_from_headersEnvironHeaders)clsenvironr   s      rG   continue_from_environSpan.continue_from_environ  s9    & $;NN9 001HSFSSrF   _sample_randc                j   U [         L a  [        R                  " S5        [        R                  " UR                  [        5      US9nUR                  [        U05        [        UR                  [        5      5      nUb!  UR                  U5        UR                  5         [        S0 UD6nSUl        U$ )aR  
Create a transaction with the given params (including any data pulled from
the ``sentry-trace`` and ``baggage`` headers).

:param headers: The dictionary with the HTTP headers to pull information from.
:param _sample_rand: If provided, we override the sample_rand value from the
    incoming headers with this value. (internal use only)
zXDeprecated: use Transaction.continue_from_headers instead of Span.continue_from_headers.r   Fr<   )r   r   r   rN   from_incoming_headerr   BAGGAGE_HEADER_NAMEupdateextract_sentrytrace_dataSENTRY_TRACE_HEADER_NAMEfreezer6   r0   )r   headersr   r   rO   sentrytrace_kwargstransactions          rG   r   Span.continue_from_headers  s    $ $;NN9 ..KK+,<
 	*G455KK01
 )MM,-
 NN!+F+-2*rF   c              #      #    U R                   (       d  g[        U R                  5       4v   U R                   R                  5       R	                  5       nU(       a  [
        U4v   gg7f)z
Creates a generator which returns the span's ``sentry-trace`` and ``baggage`` headers.
If the span's containing transaction doesn't yet have a ``baggage`` value,
this will cause one to be generated and stored.
N)r7   r   to_traceparentget_baggage	serializer   )r_   rO   s     rG   iter_headersSpan.iter_headers*  sY      **
 &(;(;(===--99;EEG%w.. s   A&A(c                 p    [         R                  " S5        U(       d  gU R                  " [        U040 UD6$ )z
DEPRECATED: Use :py:meth:`sentry_sdk.tracing.Span.continue_from_headers`.

Create a ``Transaction`` with the given params, then add in data pulled from
the given ``sentry-trace`` header value before returning the ``Transaction``.
zwDeprecated: Use Transaction.continue_from_headers(headers, **kwargs) instead of from_traceparent(traceparent, **kwargs)N)r   r   r   r   )r   traceparentr   s      rG   from_traceparentSpan.from_traceparent>  sA     	A	

 ((%{3
7=
 	
rF   c                     U R                   SL a  SnOU R                   SL a  SnOS nU R                  < SU R                  < 3nUb	  USU< 3-  nU$ )NT1F0-)r1   r-   r.   )r_   r1   r
  s      rG   r  Span.to_traceparentW  sT    <<4G\\U"GG!%=G--KrF   c                 Z    U R                   (       a  U R                   R                  5       $ g)zReturns the :py:class:`~sentry_sdk.tracing_utils.Baggage`
associated with this ``Span``, if any. (Taken from the root of the span tree.)
N)r7   r  r^   s    rG   
to_baggageSpan.to_baggagef  s%    
 &&..::<<rF   c                      X R                   U'   g r\   )r   r_   keyr]   s      rG   set_tagSpan.set_tago      

3rF   c                      X R                   U'   g r\   )r   r  s      rG   set_dataSpan.set_datas  r  rF   c                 :    U R                   R                  U5        g r\   )r   r   r_   datas     rG   update_dataSpan.update_dataw  s    

$rF   c                 h    [        U R                  5      U R                  :  a  X R                  U'   g g r\   )r   r   r   )r_   flagresults      rG   set_flagSpan.set_flag{  s*    t{{d222 &KK 3rF   c                     Xl         g r\   r5   r   s     rG   r   Span.set_status  s    rF   c                 Z    [         R                  " S[        SS9  X#S.U R                  U'   gzg
.. deprecated:: 2.28.0
    This function is deprecated and will be removed in the next major release.
zq`set_measurement()` is deprecated and will be removed in the next major version. Please use `set_data()` instead.r   r   )r]   unitNr   r   r   r   r_   r;   r]   r-  s       rG   set_measurementSpan.set_measurement  .     		

 .3#A4 rF   c                     UbN  U R                  [        R                  [        U5      5        Ub!  U R                  [        R                  U5        g g g r\   )r  r
   	THREAD_IDrA   THREAD_NAMEr_   	thread_idthread_names      rG   
set_threadSpan.set_thread  sF      MM(,,c)n=&h22K@ ' !rF   c                 L    Ub!  U R                  [        R                  U5        g g r\   )r  r
   PROFILER_IDr_   rQ   s     rG   r   Span.set_profiler_id  s!    "MM(..< #rF   c                     U R                  S[        U5      5        U R                  [        R                  U5        U R                  [        U5      5        g )Nzhttp.status_code)r  rA   r  r
   HTTP_STATUS_CODEr   r   r_   http_statuss     rG   set_http_statusSpan.set_http_status  s@    K 0	
 	h//=6{CDrF   c                      U R                   S:H  $ )Nokr)  r^   s    rG   
is_successSpan.is_success  s    {{d""rF   c                    U R                   b  g U(       aA  [        U[        5      (       a%  [        R                  " U[
        R                  5      nX l         O6[        5       U R                  -
  nU R                  [        US-  S9-   U l          U=(       d    [        R                  " 5       n[        X5        g! [         a,    [        R                  " [
        R                  5      U l          N_f = f)a  
Sets the end timestamp of the span.

Additionally it also creates a breadcrumb from the span,
if the span represents a database or HTTP request.

:param scope: The scope to use for this transaction.
    If not provided, the current scope will be used.
:param end_timestamp: Optional timestamp that should
    be used as timestamp instead of the current time.

:return: Always ``None``. The type is ``Optional[str]`` to match
    the return value of :py:meth:`sentry_sdk.tracing.Transaction.finish`.
Ni  )microseconds)r   r   rD   r   r   r   r   r   r   r8   r   r   r   r   r   "maybe_create_breadcrumbs_from_span)r_   r9   end_timestampelapseds       rG   r   Span.finish  s      >>%	8mU33$,$:$:=(,,$WM!.)+d.P.PP!%!5!5	!(49 " 7557*57  	8%\\(,,7DN	8s   AB8 5B8 83C.-C.c           
         U R                   U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  S.	nU R                  (       a  U R                  U R                  S'   U R                  b%  U R                  R                  5       nU(       a  X!S'   [        U R                  5      S:  a  U R                  US'   U R                  nU(       a  X1S'   0 nUR                  U R                   5        UR                  U R"                  5        U(       a  XAS'   U$ )z5Returns a JSON-compatible representation of the span.)	r-   r.   r/   r0   r2   r3   r8   r   r:   r5   _metrics_summaryr   measurementstagsr   )r-   r.   r/   r0   r2   r3   r8   r   r:   r5   r   r   to_jsonr   r   r   r   r   )r_   r   metrics_summaryrR  r   s        rG   rS  Span.to_json  s   
 ||"11&*&A&A''++#33kk

 ;;#';;DJJx !!-"44<<>O)8%&t!!"Q&!%!3!3B~zzvJDKK DJJvJ	rF   c                 "   U R                   U R                  U R                  U R                  U R                  U R
                  S.nU R                  (       a  U R                  US'   U R                  (       a+  U R                  R                  5       R                  5       US'   0 nU R                  R                  [        R                  5      nUb  X2S'   U R                  R                  [        R                  5      nUb  XBS'   U(       a  X!S'   U$ )N)r-   r.   r/   r2   r3   r:   r5   dynamic_sampling_contextz	thread.idzthread.namer   )r-   r.   r/   r2   r3   r:   r5   r7   r  rW  r   r   r
   r4  r5  )r_   r   r   r7  r8  s        rG   get_trace_contextSpan.get_trace_context  s     ||"11''++kk
 ;;;;BxL&&++779RRT )* JJNN8#5#56	  )jjnnX%9%9:""-vJ	rF   c                 d    U R                   R                  [        R                  5      nUc  g SU0$ )NrQ   )r   r   r
   r<  r=  s     rG   get_profile_contextSpan.get_profile_context  s4    jjnnX%9%9: ;
 	
rF   c                 >    [        5       u  pU R                  X5        g r\   )r   r9  r6  s      rG   r   Span.update_active_thread$  s    !8!:		/rF   )r   r   r   r   r   r   r   r   r   r   r   r   r3   r4   r2   r:   r/   r0   r1   r9   r8   r5   r   )NNNTNNNNNNNNmanualN NN)+r=   r>   r?   r@   r   r   r   r   propertyr-   setterr.   r   r   r   r   r7   r   SENTRYr   classmethodr   r   r  r  r  r  r  r  r!  r&  r   r0  r9  r   rC  rG  r   rS  rX  r[  r   rE   r<   rF   rG   r   r      s{   :I: ##@0H8
   __    ^^ 
  	, 	, (4':': (T T T2 
 	- -^/( 
 
0   '
BA=
E#$L%NB
0rF   r   c                      ^  \ rS rSrSrSrSSS\R                  4U 4S jjrS r	S r
U 4S	 jrU 4S
 jr\S 5       rS r  SSS.U 4S jjjrSS jrS rU 4S jrU 4S jrU 4S jrS rS rSrU =r$ )r6   i*  a1  The Transaction is the root element that holds all the spans
for Sentry performance instrumentation.

:param name: Identifier of the transaction.
    Will show up in the Sentry UI.
:param parent_sampled: Whether the parent transaction was sampled.
    If True this transaction will be kept, if False it will be discarded.
:param baggage: The W3C baggage header value.
    (see https://www.w3.org/TR/baggage/)
:param source: A string describing the source of the transaction name.
    This will be used to determine the transaction's type.
    See https://develop.sentry.dev/sdk/event-payloads/transaction/#transaction-annotations
    for more information. Default "custom".
:param kwargs: Additional arguments to be passed to the Span constructor.
    See :py:class:`sentry_sdk.tracing.Span` for available arguments.
)
r;   rL   rM   sample_rater   	_contexts_profile_continuous_profile_baggager   ra  Nc                 6  > [         TU ]  " S0 UD6  Xl        X@l        S U l        X l        0 U l        0 U l        S U l        S U l	        X0l
        U R                  c  S OU R                  R                  5       nUb  X`l        g [        U R                  5      U l        g Nr<   )superr   r;   rL   rh  rM   r   ri  rj  rk  rl  r   _generate_sample_randr-   )r_   r;   rM   rO   rL   r   baggage_sample_randr   s          rG   r   Transaction.__init__J  s     	"6"	,#'  MM)Dt}}/I/I/K 	 * 3 5dmm DDrF   c                    SU R                   R                  < SU R                  < SU R                  < SU R                  < SU R
                  < SU R                  < SU R                  < SU R                  < S	U R                  < S
3$ )Nr   z(name=z, op=r   r   r   r   z	, source=r   r   )
r   r=   r;   r2   r-   r.   r/   r1   rL   r:   r^   s    rG   r   Transaction.__repr__g  sU    
 ''		##	
rF   c                 H    U R                   SL=(       d    U R                  SL $ )zReturns whether the transaction might have been started.

If this returns False, we know that the transaction was not started
with sentry_sdk.start_transaction, and therefore the transaction will
be discarded.
NF)r   r1   r^   s    rG   _possibly_startedTransaction._possibly_startedx  s#     ""$.G$,,%2GGrF   c                    > U R                  5       (       d  [        R                  " S5        [        TU ]  5         U R
                  b  U R
                  R	                  5         U $ )NzTransaction was entered without being started with sentry_sdk.start_transaction.The transaction will not be sent to Sentry. To fix, start the transaction bypassing it to sentry_sdk.start_transaction.)rv  r   debugro  r   rj  )r_   r   s    rG   r   Transaction.__enter__  sO    %%''LL> 	==$MM##%rF   c                    > U R                   b  U R                   R                  XU5        U R                  b  U R                  R                  5         [        TU ]  XU5        g r\   )rj  r   rk  stopro  )r_   r   r]   r   r   s       rG   r   Transaction.__exit__  sN    ==$MM""2b1##/$$))+B'rF   c                     U $ )z^The root element of the span tree.
In the case of a transaction it is the transaction itself.
r<   r^   s    rG   r7   "Transaction.containing_transaction  s	     rF   c                     UnUb  [         R                  " S[        SS9  Un[        U[        R
                  5      (       a&  [         R                  " S[        SS9  UR                  $ U$ )z
Logic to get the scope from the arguments passed to finish. This
function exists for backwards compatibility with the old finish.

TODO: Remove this function in the next major version.
zMThe `hub` parameter is deprecated. Please use the `scope` parameter, instead.   r   zDPassing a Hub to finish is deprecated. Please pass a Scope, instead.)r   r   r   r   r   Hubr9   )r_   	scope_arghub_argscope_or_hubs       rG   _get_scope_from_finish_args'Transaction._get_scope_from_finish_args  se     !MM_" #LlJNN33MMV"  %%%rF   r4   c          	      6  > U R                   b  gU R                  X5      nU=(       d(    U R                  =(       d    [        R                  " 5       n[        R
                  " 5       nUR                  5       (       d  gU R                  c  U R                  SL a  [        R                  " S5        O[        R                  " S5        UR                  (       a~  [        UR                  5      (       ad  UR                  (       a  UR                  R                  S:  a  SnOSnUR                  R!                  USS	9  UR                  R!                  US
S	9  gU R"                  (       d  [        R$                  " S5        SU l        [&        TU ]Q  X5        U R                  (       d$  U R                  c  [        R$                  " S5        gU R                  R*                   Vs/ s H"  nUR                   c  M  UR-                  5       PM$     nn[/        U R                  R*                  5      [/        U5      -
  nXR                  R0                  -   n	SU l        0 n
U
R3                  U R4                  5        U
R3                  SU R7                  5       05        U R9                  5       nUb  U
R3                  SU05        SU R"                  SU R:                  0U
U R<                  U R                   U R>                  US.nU	S:  a  XS'   U R@                  b5  U R@                  RC                  5       (       a  U R@                  US'   SU l         U RD                  US'   U RF                  b%  U RF                  R-                  5       nU(       a  XS'   URI                  U5      $ s  snf )a  Finishes the transaction and sends it to Sentry.
All finished spans in the transaction will also be sent to Sentry.

:param scope: The Scope to use for this transaction.
    If not provided, the current Scope will be used.
:param end_timestamp: Optional timestamp that should
    be used as timestamp instead of the current time.
:param hub: The hub to use for this transaction.
    This argument is DEPRECATED. Please use the `scope`
    parameter, instead.

:return: The event ID if the transaction was sent to Sentry,
    otherwise None.
NFz.Discarding transaction because sampled = FalsezSDiscarding transaction because it was not started with sentry_sdk.start_transactionr   backpressurerh  r  )data_categoryr   zCTransaction has no name, falling back to `<unlabeled transaction>`.z<unlabeled transaction>z1Discarding transaction without sampling decision.traceprofilerL   )typer  transaction_infocontextsrR  r   r8   r   _dropped_spansrQ  rP  )%r   r  r9   r   r   r   	is_activer   r1   r   ry  	transporthas_tracing_enabledr   monitordownsample_factorrecord_lost_eventr;   r   ro  r   r   rS  r   r   r   ri  rX  r[  rL   r   r8   rj  validr   r   capture_event)r_   r9   rL  r4   clientreasonr   finished_spanslen_diffr   r  profile_contexteventrT  r   s                 rG   r   Transaction.finish  s    , >>% 00
 EEz'C'C'E&&(!!&||u$MNi $7$G$G>>fnn&F&F&J+F*F  2262W   2262PyyNNU 2DIu,|| ||#RS ++11
1~~ DLLN1 	 
 t**001C4GG #6#6#D#DD #'$"8"8":;<224&OOY89 "99!)4;; 7 JJ#33#	
 1&3"#==$)<)<)>)>#}}E) DM $ 2 2n !!-"44<<>O,;()""5))c
s    N5Nc                 Z    [         R                  " S[        SS9  X#S.U R                  U'   gr,  r.  r/  s       rG   r0  Transaction.set_measurementM  r2  rF   c                      X R                   U'   g)zSets a context. Transactions can have multiple contexts
and they should follow the format described in the "Contexts Interface"
documentation.

:param key: The name of the context.
:param value: The information about the context.
N)ri  r  s      rG   set_contextTransaction.set_context[  s     $srF   c                 L   > [         TU ]  U5        U R                  SSU05        g)zqSets the status of the Transaction according to the given HTTP status.

:param http_status: The HTTP status code.responsestatus_codeN)ro  rC  r  )r_   rB  r   s     rG   rC  Transaction.set_http_statusf  s'    
 	,m[%ABrF   c                 ~   > [         TU ]  5       nU R                  US'   U R                  US'   U R                  US'   U$ )z<Returns a JSON-compatible representation of the transaction.r;   rL   r1   )ro  rS  r;   rL   r1   )r_   r   r   s     rG   rS  Transaction.to_jsonn  s=     W_YY6
{{89	rF   c                 d   > [         TU ]  5       nU R                  (       a  U R                  US'   U$ )Nr   )ro  rX  r   )r_   trace_contextr   s     rG   rX  Transaction.get_trace_contexty  s+    13::$(JJM&!rF   c                     U R                   (       a  U R                   R                  (       a  [        R                  " U 5      U l         U R                   $ )zReturns the :py:class:`~sentry_sdk.tracing_utils.Baggage`
associated with the Transaction.

The first time a new baggage with Sentry items is made,
it will be frozen.)rl  mutablerN   populate_from_transactionr^   s    rG   r  Transaction.get_baggage  s3     }} 5 5#==dCDM}}rF   c           
         [         R                  " 5       nSR                  U R                  (       a  SU R                  -   S-   OSU R                  S9n[        UR                  5      (       d  SU l        gU R                  b  [        U R                  5      U l	        g[        UR                  R                  S5      5      (       a  UR                  S   " U5      OUS	   b  US	   OUR                  S
   n[        USS9(       d+  [        R                  " SR                  US95        SU l        g[        U5      U l	        UR                  (       a,  U =R                  SUR                  R                   -  -  sl	        U R                  (       dW  [        R"                  " SR                  U[        UR                  R                  S5      5      (       a  SOSS95        SU l        gU R$                  [&        R(                  " U R                  5      :  U l        U R                  (       a$  [        R"                  " SR                  US95        g[        R"                  " SR                  UU R                  S95        g)a  
Sets the transaction's sampling decision, according to the following
precedence rules:

1. If a sampling decision is passed to `start_transaction`
(`start_transaction(name: "my transaction", sampled: True)`), that
decision will be used, regardless of anything else

2. If `traces_sampler` is defined, its decision will be used. It can
choose to keep or ignore any parent sampling decision, or use the
sampling context data to make its own decision or to choose a sample
rate for the transaction.

3. If `traces_sampler` is not defined, but there's a parent sampling
decision, the parent sampling decision will be used.

4. If `traces_sampler` is not defined and there's no parent sampling
decision, `traces_sample_rate` will be used.
z{op}transaction <{name}>r   z> ra  )r2   r;   FNtraces_samplerrM   traces_sample_rateTracing)rL   zN[Tracing] Discarding {transaction_description} because of invalid sample rate.)transaction_descriptionr   z?[Tracing] Discarding {transaction_description} because {reason}z"traces_sampler returned 0 or Falseztraces_sample_rate is set to 0)r  r  z,[Tracing] Starting {transaction_description}z}[Tracing] Discarding {transaction_description} because it's not included in the random sample (sampling rate = {sample_rate}))r  rh  )r   r   formatr2   r;   r  r   r1   rD   rh  callabler   r   r   r   r  r  ry  r   r   
from_float)r_   sampling_contextr  r  rh  s        rG   _set_initial_sampling_decision*Transaction._set_initial_sampling_decision  s3   * &&("<"C"C(,dgg$Rtyy #D #

 #6>>22 DL <<#$T\\2D **+;<== NN+,-=>
 $$45A !!12^^$89 	 $K	BNN`gg,C h 
 !DL ->>6>>#C#C CC LLQXX,C $FNN$6$67G$HII == Y 	 !DL ((7+=+=d>N>N+OO<<LL>EE,C F  LL P  W  W,C $ 0 0 W rF   )rl  ri  rk  r   rj  r   r   r;   rM   rh  r1   rL   rb  r`  )r=   r>   r?   r@   r   r   rS   rc   r   r   rv  r   r   rc  r7   r  r   r0  r  rC  rS  rX  r  r  rE   __classcell__)r   s   @rG   r6   r6   *  s    "I   ''E:
"
H ( 	 	F @*
 @* @*DB	$C	
d drF   r6   c                       \ rS rSrS r\S 5       r\R                  4S jr	S r
S rS rS rS	 rS
 rS rS rS rS rS rS rS r  SSS.S jjrSS jrS rS rS rSrg)r   i  c                 4    SU R                   R                  -  $ )Nz<%s>)r   r=   r^   s    rG   r   NoOpSpan.__repr__  s    ////rF   c                     g r\   r<   r^   s    rG   r7   NoOpSpan.containing_transaction  s     rF   c                     [        5       $ r\   )r   )r_   r   r   s      rG   r   NoOpSpan.start_child  s
    zrF   c                     g)Nra  r<   r^   s    rG   r  NoOpSpan.to_traceparent  s    rF   c                     g r\   r<   r^   s    rG   r  NoOpSpan.to_baggage      rF   c                     g r\   r<   r^   s    rG   r  NoOpSpan.get_baggage  r  rF   c                     [        S5      $ rn  )iterr^   s    rG   r  NoOpSpan.iter_headers  s    BxrF   c                     g r\   r<   r  s      rG   r  NoOpSpan.set_tag      rF   c                     g r\   r<   r  s      rG   r  NoOpSpan.set_data  r  rF   c                     g r\   r<   r  s     rG   r!  NoOpSpan.update_data  r  rF   c                     g r\   r<   r   s     rG   r   NoOpSpan.set_status  r  rF   c                     g r\   r<   rA  s     rG   rC  NoOpSpan.set_http_status#  r  rF   c                     g)NTr<   r^   s    rG   rG  NoOpSpan.is_success'  r  rF   c                     0 $ r\   r<   r^   s    rG   rS  NoOpSpan.to_json+      	rF   c                     0 $ r\   r<   r^   s    rG   rX  NoOpSpan.get_trace_context/  r  rF   c                     0 $ r\   r<   r^   s    rG   r[  NoOpSpan.get_profile_context3  r  rF   Nr  c                    g)zO
The `hub` parameter is deprecated. Please use the `scope` parameter, instead.
Nr<   )r_   r9   rL  r4   s       rG   r   NoOpSpan.finish7  s     	rF   c                     g r\   r<   r/  s       rG   r0  NoOpSpan.set_measurementD  r  rF   c                     g r\   r<   r  s      rG   r  NoOpSpan.set_contextH  r  rF   c                     g r\   r<   r   s     rG   r   NoOpSpan.init_span_recorderL  r  rF   c                     g r\   r<   )r_   r  s     rG   r  'NoOpSpan._set_initial_sampling_decisionP  r  rF   r<   rb  r`  )r=   r>   r?   r@   r   rc  r7   r   re  r   r  r  r  r  r  r  r!  r   rC  rG  rS  rX  r[  r   r0  r  r   r  rE   r<   rF   rG   r   r     s    0   (4':':  
 rF   r   r2   r;   
attributestemplatec                    g r\   r<   )funcr2   r;   r  r  s        rG   r  r  W  s     	rF   c                     g r\   r<   )r  s    rG   r  r  _  s     	rF   c                B    SSK Jn  U" UUUUS9nU (       a  U" U 5      $ U$ )a	  
Decorator to start a child span around a function call.

This decorator automatically creates a new span when the decorated function
is called, and finishes the span when the function returns or raises an exception.

:param func: The function to trace. When used as a decorator without parentheses,
    this is the function being decorated. When used with parameters (e.g.,
    ``@trace(op="custom")``, this should be None.
:type func: Callable or None

: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, a default operation will
    be assigned based on the template.
:type op: str or None

:param name: The human-readable name/description for the span. If not provided,
    defaults to the function name. This provides more specific details about
    what the span represents (e.g., "GET /api/users", "process_user_data").
:type name: str 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 provide additional context about the span's execution.
:type attributes: dict[str, Any] or None

:param template: The type of span to create. This determines what kind of
    span instrumentation and data collection will be applied. Use predefined
    constants from :py:class:`sentry_sdk.consts.SPANTEMPLATE`.
    The default is `SPANTEMPLATE.DEFAULT` which is the right choice for most
    use cases.
:type template: :py:class:`sentry_sdk.consts.SPANTEMPLATE`

:returns: When used as ``@trace``, returns the decorated function. When used as
    ``@trace(...)`` with parameters, returns a decorator function.
:rtype: Callable or decorator function

Example::

    import sentry_sdk
    from sentry_sdk.consts import OP, SPANTEMPLATE

    # Simple usage with default values
    @sentry_sdk.trace
    def process_data():
        # Function implementation
        pass

    # With custom parameters
    @sentry_sdk.trace(
        op=OP.DB_QUERY,
        name="Get user data",
        attributes={"postgres": True}
    )
    def make_db_query(sql):
        # Function implementation
        pass

    # With a custom template
    @sentry_sdk.trace(template=SPANTEMPLATE.AI_TOOL)
    def calculate_interest_rate(amount, rate, years):
        # Function implementation
        pass
r   )create_span_decoratorr  )sentry_sdk.tracing_utilsr  )r  r2   r;   r  r  r  	decorators          rG   r  r  f  s3    L ?%	I rF   )rN   r   r   rp  r  rK  ignore)r   r\   )Sdecimalr   r   r   r   r   r   enumr   r   sentry_sdk.constsr   r	   r
   r   'sentry_sdk.profiler.continuous_profilerr   sentry_sdk.utilsr   r   r   r   r   typingr   collections.abcr   r   r   r   r   r   r   r   r   r   r   r   r   typing_extensionsr    r!   r"   r#   r$   (sentry_sdk.profiler.transaction_profilerr%   sentry_sdk._typesr&   r'   r(   r)   r+   rJ   rA   rP   r   r   rS   rf   LOW_QUALITY_TRANSACTION_SOURCESrb   rd   SOURCE_FOR_STYLEr   r   r   r6   r   DEFAULTr  r  rN   r   r   rp  r  rK  catch_warningssimplefilterr   sentry_sdk.metricsr   r<   rF   rG   <module>r	     s      2 2   N N C  ! AA 3#AAI@ 9aYe 9avQJe Q 3	
N   ) 

T 
 # 
 "++&00%//066!!#--&,,%++""
 $$N$ $2B	0 B	0JH$ HV]t ]@ DTLDXDX    
R@T@TRn  ($672 s   8H
H)