Ë
    õ�Dj7³  ã            
       ó  — d dl Z d dlZd dlZd dlmZmZmZ d dlZd dlmZm	Z	m
Z
 d dlmZ d dlmZmZmZmZ d dlmZ er“d dlmZmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm Z  d dlm!Z! d dl"m#Z#m$Z$  ed«      Z% e!d«      Z&d dl'Zd dl(m)Z)m*Z*m+Z+m,Z,  G d„ de#d¬«      Z- G d„ de-d¬«      Z. e#dde/i«      Z0dZ1dZ2d Z3d!Z4d"Z5d#Z6d$Z7d%Z8e4gZ9e7e7e7e5e4e7e5e5e5d&œ	Z:d'„ Z; G d(„ d)«      Z< G d*„ d+«      Z= G d,„ d-e=«      Z> G d.„ d/e=«      Z?ered6d0„«       Z@ed1„ «       Z@d6d2„Z@d d3lAmBZBmCZCmDZDmEZEmFZF  ejŽ                  «       5   ej�                  d4eI«       d d5lJmKZK ddd«       y# 1 sw Y   yxY w)7é    N)ÚdatetimeÚ	timedeltaÚtimezone)ÚINSTRUMENTERÚ
SPANSTATUSÚSPANDATA)Úget_profiler_id)Úget_current_thread_metaÚis_valid_sample_rateÚloggerÚnanosecond_time)ÚTYPE_CHECKING)ÚCallableÚMappingÚMutableMapping)ÚAny)ÚDict)ÚIterator)ÚList)ÚOptional)Úoverload)Ú	ParamSpec)ÚTuple)ÚUnion)ÚTypeVar)Ú	TypedDictÚUnpackÚPÚR)ÚEventÚMeasurementUnitÚSamplingContextÚMeasurementValuec                   óÐ   — e Zd ZU eed<   	 eed<   	 eed<   	 eed<   	 eed<   	 eed<   	 eed<   	 ed   ed	<   	 eed
<   	 ed   ed<   	 eeee	f      ed<   	 ded<   	 eed<   	 eed<   y)Ú
SpanKwargsÚ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ÚnameN)
Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__Úboolr   r   r   Úfloat© ó    úVC:\Crop_Prediction\Backend\crop-ai-system\venv\Lib\site-packages\sentry_sdk/tracing.pyr%   r%   ,   s©   … Ø‹ð	ð
 ‹ØTàÓØ<à $Ó$ØJà‹ð	ð
 ‹ð	ð
 Óð 	YàÐ&Ñ'Ó'Øsà‹Ørà (¨Ñ 7Ó7Ø8à! %¨°%¨Ñ"8Ñ9Ó9ð	ð
 "Ó!ØXà‹ð	ð ‹	Ø`r=   r%   F)Útotalc                   ó0   — e Zd ZU eed<   	 eed<   	 ded<   y)ÚTransactionKwargsÚsourceÚparent_sampledÚBaggageÚbaggageN)r5   r6   r7   r8   r9   r:   r<   r=   r>   rA   rA   g   s    … Ø‹ð	ð ÓØàÓØPr=   rA   ÚProfileContextÚprofiler_idrE   zsentry-traceÚcustomÚurlÚrouteÚviewÚ	componentÚtask)	ÚendpointÚfunction_nameÚhandler_nameÚmethod_and_path_patternÚpathÚ
route_nameÚroute_patternÚuri_templaterI   c                 ó\  — | dk  rt         j                  S d| cxk  rdk  r‘n nŽ| dk(  rt         j                  S | dk(  rt         j                  S | dk(  rt         j                  S | dk(  rt         j
                  S | dk(  rt         j                  S | dk(  rt         j                  S t         j                  S d| cxk  rd	k  ran t         j                  S | d
k(  rt         j                  S | dk(  rt         j                  S | dk(  rt         j                  S t         j                  S t         j                  S )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    r>   Úget_span_status_from_http_codere   š   s  € ð ˜#ÒÜ�}‰}Ðà	Ð Ô	& 3Õ	&Ø˜sÒ"Ü×/Ñ/Ð/Ø Ò$Ü×'Ñ'Ð'Ø Ò$Ü×0Ñ0Ð0Ø Ò$Ü×1Ñ1Ð1Ø Ò$Ü×-Ñ-Ð-Ø Ò$Ü×,Ñ,Ð,ä×.Ñ.Ð.à	Ð Ô	& 3Ô	&ô ×#Ñ#Ð#ð ˜sÒ"Ü×/Ñ/Ð/Ø Ò$Ü×+Ñ+Ð+Ø Ò$Ü×)Ñ)Ð)ä×,Ñ,Ð,ä×#Ñ#Ð#r=   c                   ó    — e Zd ZdZdZd„ Zd„ Zy)Ú_SpanRecorderz5Limits the number of spans recorded in a transaction.©ÚmaxlenÚspansc                 ó&   — |dz
  | _         g | _        y )Né   rh   ©Úselfri   s     r>   Ú__init__z_SpanRecorder.__init__Æ   s   € ð ˜q‘jˆŒØˆ�
r=   c                 óŽ   — t        | j                  «      | j                  kD  rd |_        y | j                  j	                  |«       y ©N)Úlenrj   ri   Ú_span_recorderÚappend)rn   Úspans     r>   Úaddz_SpanRecorder.addÐ   s0   € äˆt�z‰z‹?˜TŸ[™[Ò(Ø"&ˆDÕà�J‰J×Ñ˜dÕ#r=   N)r5   r6   r7   Ú__doc__Ú	__slots__ro   rv   r<   r=   r>   rg   rg   Á   s   „ Ù?à#€Iòó$r=   rg   c                   ó  — e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
ed
„ «       Zej                  fd„Zed„ «       Zed„ «       Zd„ Zed„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zd d„Zd„ Zd„ Zd„ Zd„ Zd!d„Zd„ Z d„ Z!d„ Z"d„ Z#y)"ÚSpanak  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.
    )r&   r'   r(   r)   r*   r+   r,   Ú_measurementsr1   Ú_start_timestamp_monotonic_nsr.   Ú	timestampÚ_tagsÚ_datars   r-   Ú_context_manager_stateÚ_containing_transactionÚ_local_aggregatorr2   r3   r4   Nc                 óZ  — |xs t        j                  «       j                  | _        |xs! t        j                  «       j                  dd  | _        || _        || _        || _        || _        |xs || _	        |	| _
        || _        || _        || _        i | _        i | _        i | _        |
| _        |�;t%        j&                  dt(        d¬«       | j                  xs |j                  | _        |€$t+        j,                  t.        j0                  «      }n4t3        |t4        «      r$t+        j6                  |t.        j0                  «      }|| _        	 t;        «       | _        d | _         d | _!        d | _"        | jG                  «        | jI                  tK        «       «       y # t>        $ r Y ŒJw xY w)Né   z>The `hub` parameter is deprecated. Please use `scope` instead.é   ©Ú
stacklevel)&ÚuuidÚuuid4Úhexr&   r'   r(   r)   r*   r+   r,   r.   r-   r2   r3   r{   r~   r   r�   ÚwarningsÚwarnÚDeprecationWarningr   Únowr   ÚutcÚ
isinstancer;   Úfromtimestampr1   r   r|   ÚAttributeErrorr}   rs   r‚   Úupdate_active_threadÚset_profiler_idr	   )rn   r&   r'   r(   r)   r*   r+   r,   r-   r.   r0   r1   r2   r3   r4   s                  r>   ro   zSpan.__init__  sm  € ð$ !Ò4¤D§J¡J£L×$4Ñ$4ˆŒØÒ7¤$§*¡*£,×"2Ñ"2°2°3Ð"7ˆŒØ,ˆÔØ&<ˆÔ#ØˆŒØˆŒØÒ. ;ˆÔØˆŒØˆŒØˆŒ
ØˆŒØˆÔØˆŒ
ØˆŒ
Ø'=ˆÔ$àˆ?Ü�M‰MØPÜ"Øõð Ÿ™Ò0 s§y¡yˆDŒJàÐ"Ü&Ÿl™l¬8¯<©<Ó8‰OÜ˜¬Ô/Ü&×4Ñ4°_ÄhÇlÁlÓSˆOØ.ˆÔð	ô 2AÓ1BˆDÔ.ð
 ˆŒà"ˆÔØ!%ˆÔà×!Ñ!Ô#Ø×Ñœ_Ó.Õ/øô ò 	Ùð	ús   ÅF Æ	F*Æ)F*c                 ó>   — | j                   €t        |«      | _         y y rq   )rs   rg   rm   s     r>   Úinit_span_recorderzSpan.init_span_recorderQ  s    € à×ÑÐ&Ü"/°Ó"7ˆDÕð 'r=   c                 óD   — | j                   }|€t        «       x}| _         |S rq   )r‚   ÚLocalAggregator)rn   Úrvs     r>   Ú_get_local_aggregatorzSpan._get_local_aggregatorV  s'   € à×#Ñ#ˆØˆ:Ü*9Ó*;Ð;ˆB�Ô'Øˆ	r=   c                 óì   — d| j                   j                  ›d| j                  ›d| j                  ›d| j                  ›d| j
                  ›d| j                  ›d| j                  ›d| j                  ›d	�S )
Nú<z(op=z, description:ú, trace_id=ú
, span_id=ú, parent_span_id=ú
, sampled=ú	, origin=ú)>)	Ú	__class__r5   r+   r,   r&   r'   r(   r*   r3   ©rn   s    r>   Ú__repr__zSpan.__repr__]  sP   � ð
 —‘×'Ó'Ø—“Ø× Ó Ø—“Ø—“Ø×#Ó#Ø—“Ø—“ð
ð	
r=   c                 ó‚   — | j                   xs t        j                  «       }|j                  }| |_        ||f| _        | S rq   )r2   Ú
sentry_sdkÚget_current_scoperu   r€   )rn   r2   Úold_spans      r>   Ú	__enter__zSpan.__enter__m  s;   € à—
‘
Ò<œj×:Ñ:Ó<ˆØ—:‘:ˆØˆŒ
Ø',¨hÐ&7ˆÔ#Øˆr=   c                 ó˜   — |�| j                  t        j                  «       | j                  \  }}| `| j	                  |«       ||_        y rq   )Ú
set_statusr   rb   r€   Úfinishru   )rn   ÚtyÚvalueÚtbr2   r©   s         r>   Ú__exit__zSpan.__exit__u  sB   € àÐØ�O‰OœJ×5Ñ5Ô6à×5Ñ5‰ˆˆxØÐ'Ø�‰�EÔØˆ�
r=   c                 ó   — | j                   S )z´The ``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    r>   r0   zSpan.containing_transaction  s   € ð ×+Ñ+Ð+r=   c                 óÀ  — |j                  d«      �t        j                  dt        d¬«       t	        j
                  «       j                  d   }||k7  r
t        «       S |j                  d| j                  «       t        d| j                  | j                  | j                  dœ|¤Ž}| j                  xr | j                  j                  }|r|j                  |«       |S )	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.
        r,   zEThe `description` parameter is deprecated. Please use `name` instead.r…   r†   Úinstrumenterr*   )r&   r(   r0   r<   )Úgetr‹   rŒ   r�   r§   Ú
get_clientÚoptionsÚNoOpSpanÚ
setdefaultr*   rz   r&   r'   r0   rs   rv   )rn   r´   ÚkwargsÚconfiguration_instrumenterÚchildÚspan_recorders         r>   Ústart_childzSpan.start_child‹  sÒ   € ð �:‰:�mÓ$Ð0Ü�M‰MØWÜ"Øõô &0×%:Ñ%:Ó%<×%DÑ%DÀ^Ñ%TÐ"àÐ5Ò5Ü“:Ðà×Ñ˜) T§\¡\Ô2äð 
Ø—]‘]ØŸ<™<Ø#'×#>Ñ#>ñ
ð ñ	
ˆð ×'Ñ'ÒV¨D×,GÑ,G×,VÑ,Vð 	ñ Ø×Ñ˜eÔ$àˆr=   c                 óz   — | t         u rt        j                  d«       t        j                  t        |«      fi |¤ŽS )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.)rz   r   Úwarningr/   Úcontinue_from_headersÚEnvironHeaders)ÚclsÚenvironrº   s      r>   Úcontinue_from_environzSpan.continue_from_environµ  s9   € ð& ”$‰;Ü�N‰Nð9ôô ×0Ñ0´ÀÓ1HÑSÈFÑSÐSr=   c                 ód  — | t         u rt        j                  d«       t        j                  |j                  t        «      «      }|j                  t        |i«       t        |j                  t        «      «      }|�!|j                  |«       |j                  «        t        di |¤Ž}d|_        |S )zë
        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.
        zXDeprecated: use Transaction.continue_from_headers instead of Span.continue_from_headers.Fr<   )rz   r   rÀ   rD   Úfrom_incoming_headerrµ   ÚBAGGAGE_HEADER_NAMEÚupdateÚextract_sentrytrace_dataÚSENTRY_TRACE_HEADER_NAMEÚfreezer/   r)   )rÃ   Úheadersrº   rE   Úsentrytrace_kwargsÚtransactions         r>   rÁ   zSpan.continue_from_headersÏ  sž   € ð ”$‰;Ü�N‰Nð9ôô ×.Ñ.¨w¯{©{Ô;NÓ/OÓPˆØ�‰Ô*¨GÐ4Ô5ä5Ø�K‰KÔ0Ó1ó
Ðð Ð)Ø�M‰MÐ,Ô-ð
 �N‰NÔä!Ñ+ FÑ+ˆØ-2ˆÔ*àÐr=   c              #   óÀ   K  — | j                   syt        | j                  «       f–— | j                   j                  «       j	                  «       }|rt
        |f–— yy­w)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)r0   rË   Úto_traceparentÚget_baggageÚ	serializerÈ   )rn   rE   s     r>   Úiter_headerszSpan.iter_headersù  sZ   è ø€ ð ×*Ò*ð
 ä&¨×(;Ñ(;Ó(=Ð=Ò=à×-Ñ-×9Ñ9Ó;×EÑEÓGˆÙÜ% wÐ.Ó.ð ùs   ‚AAc                 ód   — t        j                  d«       |sy | j                  t        |ifi |¤ŽS )a  
        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      r>   Úfrom_traceparentzSpan.from_traceparent  sC   € ô 	�‰ðAô	
ñ
 Øà(ˆs×(Ñ(Ü% {Ð3ñ
Ø7=ñ
ð 	
r=   c                 ó˜   — | j                   du rd}n| j                   du rd}nd }| j                  ›d| j                  ›�}|�|d|›�z  }|S )NTÚ1FÚ0ú-)r*   r&   r'   )rn   r*   rÖ   s      r>   rÑ   zSpan.to_traceparent&  sT   € à�<‰<˜4ÑØ‰GØ�\‰\˜UÑ"Ø‰GàˆGà!%§£°·²Ð=ˆØÐÙ¡GÐ-Ñ-ˆKàÐr=   c                 óP   — | j                   r| j                   j                  «       S y)z™Returns the :py:class:`~sentry_sdk.tracing_utils.Baggage`
        associated with this ``Span``, if any. (Taken from the root of the span tree.)
        N)r0   rÒ   r¤   s    r>   Ú
to_baggagezSpan.to_baggage5  s%   € ð
 ×&Ò&Ø×.Ñ.×:Ñ:Ó<Ð<Ør=   c                 ó"   — || j                   |<   y rq   )r~   ©rn   Úkeyr¯   s      r>   Úset_tagzSpan.set_tag>  ó   € àˆ�
‰
�3Šr=   c                 ó"   — || j                   |<   y rq   )r   rß   s      r>   Úset_datazSpan.set_dataB  râ   r=   c                 ó   — || _         y rq   ©r.   ©rn   r¯   s     r>   r¬   zSpan.set_statusF  s	   € àˆ�r=   c                 ó(   — ||dœ| j                   |<   y ©N)r¯   Úunit©r{   ©rn   r4   r¯   rê   s       r>   Úset_measurementzSpan.set_measurementJ  ó   € à-2¸DÑ#Aˆ×Ñ˜4Ò r=   c                 ó¢   — |�M| j                  t        j                  t        |«      «       |�!| j                  t        j                  |«       y y y rq   )rä   r   Ú	THREAD_IDr8   ÚTHREAD_NAME©rn   Ú	thread_idÚthread_names      r>   Ú
set_threadzSpan.set_threadN  sF   € ð Ð Ø�M‰Mœ(×,Ñ,¬c°)«nÔ=àÐ&Ø—‘œh×2Ñ2°KÕ@ð 'ð !r=   c                 óJ   — |�!| j                  t        j                  |«       y y rq   )rä   r   ÚPROFILER_ID©rn   rG   s     r>   r”   zSpan.set_profiler_idW  s!   € àÐ"Ø�M‰Mœ(×.Ñ.°Õ<ð #r=   c                 ó®   — | j                  dt        |«      «       | j                  t        j                  |«       | j                  t        |«      «       y )Nzhttp.status_code)rá   r8   rä   r   ÚHTTP_STATUS_CODEr¬   re   ©rn   Úhttp_statuss     r>   Úset_http_statuszSpan.set_http_status\  s@   € à�‰Ø¤ KÓ 0ô	
ð 	�‰”h×/Ñ/°Ô=Ø�‰Ô6°{ÓCÕDr=   c                 ó    — | j                   dk(  S )NÚokræ   r¤   s    r>   Ú
is_successzSpan.is_successd  s   € à�{‰{˜dÑ"Ð"r=   c                 óÂ  — | j                   �y	 |r<t        |t        «      r$t        j                  |t
        j                  «      }|| _         n8t        «       | j                  z
  }| j                  t        |dz  ¬«      z   | _         |xs t        j                  «       }t        || «       y# t        $ r+ t        j                  t
        j                  «      | _         Y ŒXw xY w)aD  
        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�   r;   r   r‘   r   r�   r   r|   r1   r   r’   rŽ   r§   r¨   Ú"maybe_create_breadcrumbs_from_span)rn   r2   Úend_timestampÚelapseds       r>   r­   zSpan.finishh  sº   € ð  �>‰>Ð%àð	8ÙÜ˜m¬UÔ3Ü$,×$:Ñ$:¸=Ì(Ï,É,Ó$W�MØ!.�•ä)Ó+¨d×.PÑ.PÑP�Ø!%×!5Ñ!5¼	Ø!(¨4¡ô9ñ "�”ð Ò7œ×5Ñ5Ó7ˆÜ*¨5°$Ô7àøô ò 	8Ü%Ÿ\™\¬(¯,©,Ó7ˆDŽNð	8ús   �A6B* Â*1CÃCc           
      ó  — | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  dœ	}| j                  r| j                  | j                  d<   | j                  �!| j                  j                  «       }|r||d<   t        | j                  «      dkD  r| j                  |d<   | j                  }|r||d<   | j                  }|r||d<   |S )z5Returns a JSON-compatible representation of the span.)	r&   r'   r(   r)   r+   r,   r1   r}   r3   r.   Ú_metrics_summaryr   ÚmeasurementsÚtagsÚdata)r&   r'   r(   r)   r+   r,   r1   r}   r3   r.   r~   r‚   Úto_jsonrr   r{   r   )rn   r™   Úmetrics_summaryr	  r
  s        r>   r  zSpan.to_jsonŽ  sí   € ð
 Ÿ™Ø—|‘|Ø"×1Ñ1Ø&*×&AÑ&AØ—'‘'Ø×+Ñ+Ø#×3Ñ3ØŸ™Ø—k‘kñ

ˆð �;Š;Ø#'§;¡;ˆD�J‰J�xÑ à×!Ñ!Ð-Ø"×4Ñ4×<Ñ<Ó>ˆOÙØ)8�Ð%Ñ&äˆt×!Ñ!Ó" QÒ&Ø!%×!3Ñ!3ˆBˆ~Ñà�z‰zˆÙØˆBˆv‰Jà�z‰zˆÙØˆBˆv‰Jàˆ	r=   c                 ó  — | j                   | j                  | j                  | j                  | j                  | j
                  dœ}| j                  r| j                  |d<   | j                  r+| j                  j                  «       j                  «       |d<   i }| j                  j                  t        j                  «      }|�||d<   | j                  j                  t        j                  «      }|�||d<   |r||d<   |S )N)r&   r'   r(   r+   r,   r3   r.   Údynamic_sampling_contextz	thread.idzthread.namer
  )r&   r'   r(   r+   r,   r3   r.   r0   rÒ   r  r   rµ   r   rð   rñ   )rn   r™   r
  ró   rô   s        r>   Úget_trace_contextzSpan.get_trace_context³  sæ   € ð Ÿ™Ø—|‘|Ø"×1Ñ1Ø—'‘'Ø×+Ñ+Ø—k‘kñ
ˆð �;Š;ØŸ;™;ˆBˆx‰Là×&Ò&à×+Ñ+×7Ñ7Ó9×RÑRÓTð Ð)Ñ*ð ˆà—J‘J—N‘N¤8×#5Ñ#5Ó6ˆ	ØÐ Ø )ˆD�Ñà—j‘j—n‘n¤X×%9Ñ%9Ó:ˆØÐ"Ø"-ˆD�ÑáØˆBˆv‰Jàˆ	r=   c                 ób   — | j                   j                  t        j                  «      }|€y d|iS )NrG   )r   rµ   r   r÷   rø   s     r>   Úget_profile_contextzSpan.get_profile_contextÔ  s4   € à—j‘j—n‘n¤X×%9Ñ%9Ó:ˆØÐØð ˜;ð
ð 	
r=   c                 óB   — t        «       \  }}| j                  ||«       y rq   )r
   rõ   rò   s      r>   r“   zSpan.update_active_threadÞ  s   € ä!8Ó!:Ñˆ	�;Ø�‰˜	 ;Õ/r=   )NNNTNNNNNNNNÚmanualN©Ú ©NN)$r5   r6   r7   rw   rx   ro   r–   rš   r¥   rª   r±   Úpropertyr0   r   ÚSENTRYr¾   ÚclassmethodrÅ   rÁ   rÔ   r×   rÑ   rÝ   rá   rä   r¬   rí   rõ   r”   rý   r   r­   r  r  r  r“   r<   r=   r>   rz   rz   Ø   s  „ ñð:€Ið6 ØØØ#ØØØØØØ#ØØØØó>0òD8ò
ò
ò òð ñ	,ó ð	,ð (4×':Ñ':ó (ðT ñTó ðTð2 ñ'ó ð'òR/ð( ñ
ó ð
ò0òò ò òóBòAò=ò
Eò#ó$òL#òJòB
ó0r=   rz   c                   ó´   ‡ — e Zd ZdZdZdddefˆ fd„	Zd„ Zd„ Zˆ fd„Z	ˆ fd	„Z
ed
„ «       Zd„ Z	 	 dddœˆ fd„Zdd„Zd„ Zˆ fd„Zˆ fd„Zˆ fd„Zd„ Zd„ Zˆ xZS )r/   ai  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.
    )r4   rB   rC   Úsample_rater{   Ú	_contextsÚ_profileÚ_baggager  Nc                 ó”   •— t        ‰| �  di |¤Ž || _        || _        d | _        || _        i | _        i | _        d | _        || _	        y ©Nr<   )
Úsuperro   r4   rB   r  rC   r{   r  r  r  )rn   r4   rC   rE   rB   rº   r£   s         €r>   ro   zTransaction.__init__  sU   ø€ ô 	‰ÑÑ"˜6Ò"àˆŒ	ØˆŒØˆÔØ,ˆÔØˆÔØˆŒàð 	Œð  ˆ�r=   c                 ó  — d| j                   j                  ›d| j                  ›d| j                  ›d| j                  ›d| j
                  ›d| j                  ›d| j                  ›d| j                  ›d	| j                  ›d
�S )Nrœ   z(name=z, op=r�   rž   rŸ   r    z	, source=r¡   r¢   )
r£   r5   r4   r+   r&   r'   r(   r*   rB   r3   r¤   s    r>   r¥   zTransaction.__repr__  sU   � ð
 —‘×'Ó'Ø—	“	Ø—“Ø—“Ø—“Ø×#Ó#Ø—“Ø—“Ø—“ðð	
r=   c                 ó>   — | j                   duxs | j                  du S )zòReturns 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)rs   r*   r¤   s    r>   Ú_possibly_startedzTransaction._possibly_started*  s#   € ð ×"Ñ"¨$Ð.ÒG°$·,±,À%Ð2GÐGr=   c                 óº   •— | j                  «       st        j                  d«       t        ‰| �  «        | j
                  �| j
                  j	                  «        | S )NzÇTransaction 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.)r$  r   Údebugr!  rª   r  )rn   r£   s    €r>   rª   zTransaction.__enter__6  sL   ø€ à×%Ñ%Ô'Ü�L‰Lð>ôô 	‰ÑÔà�=‰=Ð$Ø�M‰M×#Ñ#Ô%àˆr=   c                 óz   •— | j                   �| j                   j                  |||«       t        ‰| �  |||«       y rq   )r  r±   r!  )rn   r®   r¯   r°   r£   s       €r>   r±   zTransaction.__exit__F  s4   ø€ à�=‰=Ð$Ø�M‰M×"Ñ" 2 u¨bÔ1ä‰Ñ˜˜U BÕ'r=   c                 ó   — | S )znThe root element of the span tree.
        In the case of a transaction it is the transaction itself.
        r<   r¤   s    r>   r0   z"Transaction.containing_transactionM  s	   € ð ˆr=   c                 óÎ   — |}|�t        j                  dt        d¬«       |}t        |t        j
                  «      r(t        j                  dt        d¬«       |j                  S |S )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§   ÚHubr2   )rn   Ú	scope_argÚhub_argÚscope_or_hubs       r>   Ú_get_scope_from_finish_argsz'Transaction._get_scope_from_finish_argsY  sb   € ð !ˆØÐÜ�M‰MØ_Ü"Øõð #ˆLä�l¤J§N¡NÔ3Ü�M‰MØVÜ"Øõð  ×%Ñ%Ð%àÐr=   ©r-   c          	      ó"  •— | j                   �y| j                  ||«      }|xs" | j                  xs t        j                  «       }t        j
                  «       }|j                  «       sy| j                  €¿| j                  du rt        j                  d«       nt        j                  d«       |j                  ryt        |j                  «      rd|j                  r|j                  j                  dkD  rd}nd}|j                  j!                  |d¬	«       |j                  j!                  |d
¬	«       y| j"                  st        j$                  d«       d| _        t&        ‰| �Q  ||«       | j                  s"| j                  €t        j$                  d«       y| j                  j*                  D �cg c]  }|j                   �|j-                  «       ‘Œ  }}d| _        i }|j/                  | j0                  «       |j/                  d| j3                  «       i«       | j5                  «       }	|	�|j/                  d|	i«       d| j"                  d| j6                  i|| j8                  | j                   | j:                  |dœ}
| j<                  �0| j<                  j?                  «       r| j<                  |
d<   d| _        | j@                  |
d<   | jB                  �!| jB                  j-                  «       }|r||
d<   |jE                  |
«      S c c}w )au  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   Úbackpressurer  rÏ   )Údata_categoryru   zCTransaction has no name, falling back to `<unlabeled transaction>`.z<unlabeled transaction>z1Discarding transaction without sampling decision.ÚtraceÚprofilerB   )ÚtyperÏ   Útransaction_infoÚcontextsr	  r}   r1   rj   r  r  )#r}   r/  r2   r§   r¨   r¶   Ú	is_activers   r*   r   r&  Ú	transportÚhas_tracing_enabledr·   ÚmonitorÚdownsample_factorÚrecord_lost_eventr4   rÀ   r!  r­   rj   r  rÉ   r  r  r  rB   r~   r1   r  Úvalidr{   r‚   Úcapture_event)rn   r2   r  r-   ÚclientÚreasonru   Úfinished_spansr8  Úprofile_contextÚeventr  r£   s               €r>   r­   zTransaction.finishz  s´  ø€ ð, �>‰>Ð%àð ×0Ñ0Ø�3ó
ˆð ÒE˜Ÿ™ÒE¤z×'CÑ'CÓ'EˆÜ×&Ñ&Ó(ˆà×ÑÔ!àà×ÑÐ&à�|‰|˜uÑ$Ü—‘ÐMÕNä—‘Øiôð ×ÒÔ$7¸¿¹Ô$GØ—>’> f§n¡n×&FÑ&FÈÒ&JØ+‘Fà*�Fà× Ñ ×2Ñ2°6ÈÐ2ÔWð × Ñ ×2Ñ2°6ÈÐ2ÔPØà�yŠyÜ�N‰NØUôð 2ˆDŒIä‰‰�u˜mÔ,à�|Š|ð �|‰|Ð#Ü—‘ÐRÔSàð ×+Ñ+×1Ñ1ö
àØ�~‰~Ð)ð �L‰L�Nð
ˆð 
ð #ˆÔàˆØ�‰˜Ÿ™Ô'Ø�‰˜ $×"8Ñ"8Ó":Ð;Ô<Ø×2Ñ2Ó4ˆØÐ&Ø�O‰O˜Y¨Ð8Ô9ð "ØŸ9™9Ø!)¨4¯;©;Ð 7Ø Ø—J‘JØŸ™Ø#×3Ñ3Ø#ñ	
ˆð �=‰=Ð$¨¯©×)<Ñ)<Ô)>Ø#Ÿ}™}ˆE�)ÑØ ˆDŒMà $× 2Ñ 2ˆˆnÑð ×!Ñ!Ð-Ø"×4Ñ4×<Ñ<Ó>ˆOÙØ,;�Ð(Ñ)à×"Ñ" 5Ó)Ð)ùòW
s   Æ5#Lc                 ó(   — ||dœ| j                   |<   y ré   rë   rì   s       r>   rí   zTransaction.set_measurementö  rî   r=   c                 ó"   — || j                   |<   y)a  Sets 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)r  rß   s      r>   Úset_contextzTransaction.set_contextú  s   € ð $ˆ�‰�sÒr=   c                 óL   •— t         ‰| �  |«       | j                  dd|i«       y)zySets the status of the Transaction according to the given HTTP status.

        :param http_status: The HTTP status code.ÚresponseÚstatus_codeN)r!  rý   rH  )rn   rü   r£   s     €r>   rý   zTransaction.set_http_status  s'   ø€ ô
 	‰Ñ Ô,Ø×Ñ˜ m°[Ð%AÕBr=   c                 ó~   •— t         ‰| �  «       }| j                  |d<   | j                  |d<   | j                  |d<   |S )z<Returns a JSON-compatible representation of the transaction.r4   rB   r*   )r!  r  r4   rB   r*   )rn   r™   r£   s     €r>   r  zTransaction.to_json  s=   ø€ ô ‰W‰_Óˆà—Y‘Yˆˆ6‰
Ø—{‘{ˆˆ8‰ØŸ™ˆˆ9‰àˆ	r=   c                 óZ   •— t         ‰| �  «       }| j                  r| j                  |d<   |S )Nr
  )r!  r  r   )rn   Útrace_contextr£   s     €r>   r  zTransaction.get_trace_context  s+   ø€ ä™Ñ1Ó3ˆà�:Š:Ø$(§J¡JˆM˜&Ñ!àÐr=   c                 ó’   — | j                   r| j                   j                  rt        j                  | «      | _         | j                   S )z¾Returns 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.)r  ÚmutablerD   Úpopulate_from_transactionr¤   s    r>   rÒ   zTransaction.get_baggage!  s3   € ð �}Š} §¡× 5Ò 5Ü#×=Ñ=¸dÓCˆDŒMà�}‰}Ðr=   c           
      ó¢  — t        j                  «       }dj                  | j                  rd| j                  z   dz   nd| j                  ¬«      }t        |j                  «      sd| _        y| j                  �t        | j                  «      | _	        yt        |j                  j                  d«      «      r |j                  d   |«      n|d	   �|d	   n|j                  d
   }t        |d¬«      s-t        j                  dj                  |¬«      «       d| _        yt        |«      | _	        |j                  r,| xj                  d|j                  j                   z  z  c_	        | j                  sTt        j"                  dj                  |t        |j                  j                  d«      «      rdnd¬«      «       d| _        yt%        j$                  «       | j                  k  | _        | j                  r&t        j"                  dj                  |¬«      «       yt        j"                  dj                  || j                  ¬«      «       y)aO  
        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> r  )r+   r4   FNÚtraces_samplerrC   Útraces_sample_rateÚTracing)rB   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)rV  rB  z,[Tracing] Starting {transaction_description}z}[Tracing] Discarding {transaction_description} because it's not included in the random sample (sampling rate = {sample_rate}))rV  r  )r§   r¶   Úformatr+   r4   r;  r·   r*   r;   r  Úcallablerµ   r   r   rÀ   r<  r=  r&  Úrandom)rn   Úsampling_contextrA  rV  r  s        r>   Ú_set_initial_sampling_decisionz*Transaction._set_initial_sampling_decision.  s!  € ô* ×&Ñ&Ó(ˆà"<×"CÑ"CØ(,¯ª��d—g‘g‘ Ò$°R¸t¿y¹yð #Dó #
Ðô
 # 6§>¡>Ô2Ø ˆDŒLØð �<‰<Ð#Ü$ T§\¡\Ó2ˆDÔØô ˜Ÿ™×*Ñ*Ð+;Ó<Ô=ð -ˆF�N‰NÐ+Ñ,Ð-=Ô>ð
 $Ð$4Ñ5ÐAð !Ð!1Ò2à—^‘^Ð$8Ñ9ð 	ô $ K¸	ÕBÜ�N‰NØ`×gÑgØ,Cð hó ôð
 !ˆDŒLØä  Ó-ˆÔà�>Š>Ø×Ò  6§>¡>×#CÑ#CÑ CÑCÕð ×ÒÜ�L‰LØQ×XÑXØ,Cô $ F§N¡N×$6Ñ$6Ð7GÓ$HÔIñ =à=ð Yó ô	ð !ˆDŒLØô
 —}‘}“¨×)9Ñ)9Ñ9ˆŒà�<Š<Ü�L‰LØ>×EÑEØ,Cð Fó õô �L‰Lð P÷  Wñ  WØ,CØ $× 0Ñ 0ð Wó õr=   r  r  )r5   r6   r7   rw   rx   ÚTRANSACTION_SOURCE_CUSTOMro   r¥   r$  rª   r±   r  r0   r/  r­   rí   rH  rý   r  r  rÒ   r[  Ú__classcell__)r£   s   @r>   r/   r/   ä  s‘   ø„ ñð"
€Ið ØØØ(õ ò.
ò"
Hôô (ð ñ	ó ð	òðF Øðz*ð
 öz*óxBò	$ôCô	ôòöfr=   r/   c                   ó´   — e Zd Zd„ Zed„ «       Zej                  fd„Zd„ Z	d„ Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	 	 dddœd„Zdd„Zd„ Zd„ Zd„ Zy)r¸   c                 ó4   — d| j                   j                  z  S )Nz<%s>)r£   r5   r¤   s    r>   r¥   zNoOpSpan.__repr__˜  s   € à˜Ÿ™×/Ñ/Ñ/Ð/r=   c                  ó   — y rq   r<   r¤   s    r>   r0   zNoOpSpan.containing_transactionœ  s   € ð r=   c                 ó   — t        «       S rq   )r¸   )rn   r´   rº   s      r>   r¾   zNoOpSpan.start_child¡  s
   € ä‹zÐr=   c                  ó   — y)Nr  r<   r¤   s    r>   rÑ   zNoOpSpan.to_traceparent¥  s   € àr=   c                  ó   — y rq   r<   r¤   s    r>   rÝ   zNoOpSpan.to_baggage©  ó   € àr=   c                  ó   — y rq   r<   r¤   s    r>   rÒ   zNoOpSpan.get_baggage­  rd  r=   c                 ó   — t        d«      S r   )Úiterr¤   s    r>   rÔ   zNoOpSpan.iter_headers±  s   € ä�B‹xˆr=   c                  ó   — y rq   r<   rß   s      r>   rá   zNoOpSpan.set_tagµ  ó   € àr=   c                  ó   — y rq   r<   rß   s      r>   rä   zNoOpSpan.set_data¹  ri  r=   c                  ó   — y rq   r<   rç   s     r>   r¬   zNoOpSpan.set_status½  ri  r=   c                  ó   — y rq   r<   rû   s     r>   rý   zNoOpSpan.set_http_statusÁ  ri  r=   c                  ó   — y)NTr<   r¤   s    r>   r   zNoOpSpan.is_successÅ  rd  r=   c                 ó   — i S rq   r<   r¤   s    r>   r  zNoOpSpan.to_jsonÉ  ó   € àˆ	r=   c                 ó   — i S rq   r<   r¤   s    r>   r  zNoOpSpan.get_trace_contextÍ  ro  r=   c                 ó   — i S rq   r<   r¤   s    r>   r  zNoOpSpan.get_profile_contextÑ  ro  r=   Nr0  c                 ó   — y)z_
        The `hub` parameter is deprecated. Please use the `scope` parameter, instead.
        Nr<   )rn   r2   r  r-   s       r>   r­   zNoOpSpan.finishÕ  s   € ð 	r=   c                  ó   — y rq   r<   rì   s       r>   rí   zNoOpSpan.set_measurementâ  ri  r=   c                  ó   — y rq   r<   rß   s      r>   rH  zNoOpSpan.set_contextæ  ri  r=   c                  ó   — y rq   r<   rm   s     r>   r–   zNoOpSpan.init_span_recorderê  ri  r=   c                  ó   — y rq   r<   )rn   rZ  s     r>   r[  z'NoOpSpan._set_initial_sampling_decisionî  ri  r=   r  r  )r5   r6   r7   r¥   r  r0   r   r  r¾   rÑ   rÝ   rÒ   rÔ   rá   rä   r¬   rý   r   r  r  r  r­   rí   rH  r–   r[  r<   r=   r>   r¸   r¸   —  s’   „ ò0ð ñó ðð (4×':Ñ':ó òòòòòòòòòòòòð Øðð
 ôóòòór=   r¸   c                  ó   — y rq   r<   ©Úfuncs    r>   r4  r4  õ  ó   € ð 	r=   c                  ó   — y rq   r<   rx  s    r>   r4  r4  ú  rz  r=   c                 ó&   — ddl m} | r || «      S |S )av  
    Decorator to start a child span under the existing current transaction.
    If there is no current transaction, then nothing will be traced.

    .. code-block::
        :caption: Usage

        import sentry_sdk

        @sentry_sdk.trace
        def my_function():
            ...

        @sentry_sdk.trace
        async def my_async_function():
            ...
    r   )Ústart_child_span_decorator)Úsentry_sdk.tracing_utilsr}  )ry  r}  s     r>   r4  r4     s   € õ& Dñ Ù)¨$Ó/Ð/à)Ð)r=   )rD   rÂ   rÊ   r;  r  Úignore)r˜   rq   )Lrˆ   rY  r‹   r   r   r   r§   Úsentry_sdk.constsr   r   r   Ú'sentry_sdk.profiler.continuous_profilerr	   Úsentry_sdk.utilsr
   r   r   r   Útypingr   Úcollections.abcr   r   r   r   r   r   r   r   r   r   r   r   r   Útyping_extensionsr   r   r   r   Úsentry_sdk.profilerÚsentry_sdk._typesr    r!   r"   r#   r%   rA   r8   rF   rÈ   rË   r\  ÚTRANSACTION_SOURCE_URLÚTRANSACTION_SOURCE_ROUTEÚTRANSACTION_SOURCE_VIEWÚTRANSACTION_SOURCE_COMPONENTÚTRANSACTION_SOURCE_TASKÚLOW_QUALITY_TRANSACTION_SOURCESÚSOURCE_FOR_STYLEre   rg   rz   r/   r¸   r4  r~  rD   rÂ   rÊ   r;  r  Úcatch_warningsÚsimplefilterr�   Úsentry_sdk.metricsr˜   r<   r=   r>   ú<module>r’     sÈ  ðÛ Û Û ß 2Ñ 2ã ß @Ñ @Ý C÷ó õ !áßAÑAÝÝÝÝÝÝÝ ÝÝÝç3á�#‹€AÙ�‹€Aã÷ó ô9a�Y eõ 9aôvQ˜J¨eõ Qñ Øà˜3ð	
ó€Nð  Ð Ø)Ð ð %Ð ØÐ Ø"Ð Ø Ð Ø*Ð Ø Ð ð ð#Ð ð
 -Ø1Ø0Ø7Ø"Ø.Ø-Ø,Ø#ñ
Ð ò$$÷N$ñ $÷.I0ñ I0ôXp�$ô pôfYˆtô Yñx àòó ðð ñó ðó
*÷>õ ð €X×ÑÓñ 3à€H×Ñ˜(Ð$6Ô7Ý2÷3÷ 3ñ 3ús   ÅE7Å7F 