
    3i                     :   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJr  S SKJrJr  S SKJrJrJrJrJrJrJrJrJr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*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2  S SK3J4r4  S SK5J6r6  S SK7J8r8J9r9  S SK:J;r;  S SK<J=r=J>r>  S SK?J@r@JArAJBrBJCrC  S SKDJErEJFrF  S SKGJHrHJIrI  S SKJJr  S SKKJLrL  \R                  " \N5      rOSrPSrQSrRSrSSrTSrUSrV " S S5      rW " S S\W5      rX " S S\W5      rY " S S \ R                  5      r[ " S! S"\[5      r\S# r]S$\FS%\R                  S&\_4S' jr` " S( S)5      ra " S* S+5      rb\b" \bR                  \bR                  \bR                  \bR                  \bR                  \bR                  \bR                  \bR                  S,9rd\bR                  S\/\Q5      rf " S- S.\$R                  \a5      rg " S/ S0\g5      rh " S1 S2\$R                  5      ri " S3 S4\$R                  5      rjg)5    N)environ)time_ns)MappingProxyTypeTracebackType)AnyCallableDictIteratorListMappingMutableMappingOptionalSequenceTupleTypeUnion)filterwarnings)
deprecatedcontext)trace)BoundedAttributes)util)	OTEL_ATTRIBUTE_COUNT_LIMIT!OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT OTEL_EVENT_ATTRIBUTE_COUNT_LIMITOTEL_LINK_ATTRIBUTE_COUNT_LIMITOTEL_SDK_DISABLEDOTEL_SPAN_ATTRIBUTE_COUNT_LIMIT&OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMITOTEL_SPAN_EVENT_COUNT_LIMITOTEL_SPAN_LINK_COUNT_LIMIT)Resource)sampling)IdGeneratorRandomIdGenerator)BoundedList)InstrumentationInfoInstrumentationScope)EXCEPTION_ESCAPEDEXCEPTION_MESSAGEEXCEPTION_STACKTRACEEXCEPTION_TYPE)
NoOpTracerSpanContext)Status
StatusCode)types)_agnosticcontextmanager    c                   x    \ rS rSrSr SSSS\\R                     SS4S jjrSS	 jr	SS
 jr
SS\S\4S jjrSrg)SpanProcessor\   zInterface which allows hooks for SDK's `Span` start and end method
invocations.

Span processors can be registered directly using
:func:`TracerProvider.add_span_processor` and they are invoked
in the same order as they were registered.
NspanSpanparent_contextreturnc                     g)aJ  Called when a :class:`opentelemetry.trace.Span` is started.

This method is called synchronously on the thread that starts the
span, therefore it should not block or throw an exception.

Args:
    span: The :class:`opentelemetry.trace.Span` that just started.
    parent_context: The parent context of the span that just started.
N selfr9   r;   s      Z/home/james-whalen/.local/lib/python3.13/site-packages/opentelemetry/sdk/trace/__init__.pyon_startSpanProcessor.on_starte           c                     g)zCalled when a :class:`opentelemetry.trace.Span` is ended.

This method is called synchronously on the thread that ends the
span, therefore it should not block or throw an exception.

Args:
    span: The :class:`opentelemetry.trace.Span` that just ended.
Nr>   r@   r9   s     rA   on_endSpanProcessor.on_endt   rD   rE   c                     g)zJCalled when a :class:`opentelemetry.sdk.trace.TracerProvider` is shutdown.Nr>   r@   s    rA   shutdownSpanProcessor.shutdown~   rD   rE   timeout_millisc                     g)zExport all ended spans to the configured Exporter that have not yet
been exported.

Args:
    timeout_millis: The maximum amount of time to wait for spans to be
        exported.

Returns:
    False if the timeout is exceeded, True otherwise.
Nr>   r@   rN   s     rA   force_flushSpanProcessor.force_flush   rD   rE   r>   Nr9   ReadableSpanr<   Nr<   Ni0u  )__name__
__module____qualname____firstlineno____doc__r   context_apiContextrB   rH   rL   intboolrQ   __static_attributes__r>   rE   rA   r7   r7   \   s[     9= !!4!45 
	Y
# 
$ 
 
rE   r7   c                       \ rS rSr% Sr\\S4   \S'   S rS\SS4S	 jr	 SS
SS\
\R                     SS4S jjrSS jrSS jrSS\S\4S jjrSrg)SynchronousMultiSpanProcessor   zImplementation of class:`SpanProcessor` that forwards all received
events to a list of span processors sequentially.

The underlying span processors are called in sequential order as they were
added.
._span_processorsc                 F    SU l         [        R                  " 5       U l        g )Nr>   )re   	threadingLock_lockrK   s    rA   __init__&SynchronousMultiSpanProcessor.__init__   s     !#^^%
rE   span_processorr<   Nc                 |    U R                      U =R                  U4-  sl        SSS5        g! , (       d  f       g= fz:Adds a SpanProcessor to the list handled by this instance.Nri   re   r@   rl   s     rA   add_span_processor0SynchronousMultiSpanProcessor.add_span_processor   '    ZZ!!n%66! ZZ   -
;r9   r:   r;   c                 H    U R                    H  nUR                  XS9  M     g )Nr;   )re   rB   )r@   r9   r;   sps       rA   rB   &SynchronousMultiSpanProcessor.on_start   s"    
 ''BKKK< (rE   c                 L    U R                    H  nUR                  U5        M     g rS   )re   rH   )r@   r9   rw   s      rA   rH   $SynchronousMultiSpanProcessor.on_end   s    ''BIIdO (rE   c                 J    U R                    H  nUR                  5         M     g)z7Sequentially shuts down all underlying span processors.N)re   rL   )r@   rw   s     rA   rL   &SynchronousMultiSpanProcessor.shutdown   s    ''BKKM (rE   rN   c                     [        5       US-  -   nU R                   H1  n[        5       nXB:  a    gUR                  X$-
  S-  5      (       a  M1    g   g)a  Sequentially calls force_flush on all underlying
:class:`SpanProcessor`

Args:
    timeout_millis: The maximum amount of time over all span processors
        to wait for spans to be exported. In case the first n span
        processors exceeded the timeout followup span processors will be
        skipped.

Returns:
    True if all span processors flushed their spans within the
    given timeout, False otherwise.
i@B FT)r   re   rQ   )r@   rN   deadline_nsrw   current_time_nss        rA   rQ   )SynchronousMultiSpanProcessor.force_flush   sT     i.7"::''B%iO->>;#@W"LMM ( rE   ro   rS   rT   rV   rW   )rX   rY   rZ   r[   r\   r   r7   __annotations__rj   rq   r   r]   r^   rB   rH   rL   r_   r`   rQ   ra   r>   rE   rA   rc   rc      s     M3.//&7 74 7 9=== !!4!45= 
	=
# $  rE   rc   c                       \ rS rSrSrSS\4S jjrS\SS4S jrS	\	\/\	S
   4   S\
S\
4S jr SSSS\\R                     SS4S jjrSS jrSS jrSS\S\4S jjrSrg)ConcurrentMultiSpanProcessor   a  Implementation of :class:`SpanProcessor` that forwards all received
events to a list of span processors in parallel.

Calls to the underlying span processors are forwarded in parallel by
submitting them to a thread pool executor and waiting until each span
processor finished its work.

Args:
    num_threads: The number of threads managed by the thread pool executor
        and thus defining how many span processors can work in parallel.
num_threadsc                     SU l         [        R                  " 5       U l        [        R
                  R                  US9U l        g )Nr>   )max_workers)re   rg   rh   ri   
concurrentfuturesThreadPoolExecutor	_executor)r@   r   s     rA   rj   %ConcurrentMultiSpanProcessor.__init__   s:     !#^^%
#++>># ? 
rE   rl   r<   Nc                 |    U R                      U =R                  U4-  sl        SSS5        g! , (       d  f       g= frn   ro   rp   s     rA   rq   /ConcurrentMultiSpanProcessor.add_span_processor   rs   rt   func).Nargskwargsc                     / nU R                    H:  nU R                  R                  " U" U5      /UQ70 UD6nUR                  U5        M<     U H  nUR	                  5         M     g rS   )re   r   submitappendresult)r@   r   r   r   r   rw   futures          rA   _submit_and_await.ConcurrentMultiSpanProcessor._submit_and_await   s\     ''B^^**48EdEfEFNN6" ( FMMO rE   r9   r:   r;   c                 &    U R                  S XS9  g )Nc                     U R                   $ rS   )rB   rw   s    rA   <lambda>7ConcurrentMultiSpanProcessor.on_start.<locals>.<lambda>   s    r{{rE   rv   r   r?   s      rA   rB   %ConcurrentMultiSpanProcessor.on_start   s    
 	"D 	 	
rE   c                 *    U R                  S U5        g )Nc                     U R                   $ rS   )rH   r   s    rA   r   5ConcurrentMultiSpanProcessor.on_end.<locals>.<lambda>  s    "))rE   r   rG   s     rA   rH   #ConcurrentMultiSpanProcessor.on_end  s    3T:rE   c                 (    U R                  S 5        g)z6Shuts down all underlying span processors in parallel.c                     U R                   $ rS   )rL   r   s    rA   r   7ConcurrentMultiSpanProcessor.shutdown.<locals>.<lambda>  s    "++rE   Nr   rK   s    rA   rL   %ConcurrentMultiSpanProcessor.shutdown  s    56rE   rN   c                 8   / nU R                    H:  nU R                  R                  UR                  U5      nUR	                  U5        M<     US-  n[
        R                  R                  X%5      u  pgU(       a  gU H  nUR                  5       (       a  M    g   g)a  Calls force_flush on all underlying span processors in parallel.

Args:
    timeout_millis: The maximum amount of time to wait for spans to be
        exported.

Returns:
    True if all span processors flushed their spans within the given
    timeout, False otherwise.
g     @@FT)	re   r   r   rQ   r   r   r   waitr   )r@   rN   r   rw   r   timeout_secdone_futuresnot_done_futuress           rA   rQ   (ConcurrentMultiSpanProcessor.force_flush  s     ''B^^**2>>>JFNN6" ( %s*)3););)@)@*
& "F==?? # rE   )r   ri   re   )   rS   rT   rV   rW   )rX   rY   rZ   r[   r\   r_   rj   r7   rq   r   r   r   r   r]   r^   rB   rH   rL   r`   rQ   ra   r>   rE   rA   r   r      s    

C 
7 74 7
(;;<  	  9=

 !!4!45
 
	
;7# $  rE   r   c                       \ rS rSrSS\S\\   SS4S jjr\S\4S j5       r	\S\4S j5       r
\\R                  S\R                  4S	 j5       5       rS
rg)	EventBasei&  Nname	timestampr<   c                 B    Xl         Uc  [        5       U l        g X l        g rS   )_namer   
_timestamp)r@   r   r   s      rA   rj   EventBase.__init__'  s    
%iDO'OrE   c                     U R                   $ rS   r   rK   s    rA   r   EventBase.name.      zzrE   c                     U R                   $ rS   )r   rK   s    rA   r   EventBase.timestamp2  s    rE   c                     g rS   r>   rK   s    rA   
attributesEventBase.attributes6  s     	rE   )r   r   rS   )rX   rY   rZ   r[   strr   r_   rj   propertyr   r   abcabstractmethodr2   
Attributesr   ra   r>   rE   rA   r   r   &  s    (S (Xc] (d ( c   3   E,,   rE   r   c                      ^  \ rS rSrSrSS\4S\S\R                  S\	\
   S\	\
   SS4
U 4S	 jjjr\S\R                  4S
 j5       r\S\
4S j5       rSrU =r$ )Eventi<  zA text annotation with a set of attributes. The attributes of an event
are immutable.

Args:
    name: Name of the event.
    attributes: Attributes of the event.
    timestamp: Timestamp of the event. If `None` it will filled
        automatically.
Nr   r   r   limitr<   c                 0   > [         TU ]  X5        X l        g rS   )superrj   _attributes)r@   r   r   r   r   	__class__s        rA   rj   Event.__init__G  s     	)%rE   c                     U R                   $ rS   r   rK   s    rA   r   Event.attributesQ      rE   c                 n    [        U R                  [        5      (       a  U R                  R                  $ gNr   
isinstancer   r   droppedrK   s    rA   dropped_attributesEvent.dropped_attributesU  +    d&&(9::##+++rE   r   )rX   rY   rZ   r[   r\   (_DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMITr   r2   r   r   r_   rj   r   r   r   ra   __classcell__r   s   @rA   r   r   <  s     (,#'G&& $$& C=	&
 }& 
& &  E,,     C  rE   r   c                    ^  U 4S jnU$ )Nc                    > SnU R                      U R                  c  T" U /UQ70 UD6  OSnS S S 5        U(       a!  [        R                  STR                  5        g g ! , (       d  f       N7= f)NFTz"Tried calling %s on an ended span.)ri   	_end_timeloggerwarningrX   )r@   r   r   already_endedr   s       rA   wrapper"_check_span_ended.<locals>.wrapper]  sZ    ZZ~~%T+D+F+ $	  NN?O  Zs   A
A,r>   )r   r   s   ` rA   _check_span_endedr   \  s    	P NrE   r   r   r<   c                 v    [        U =(       a(    U R                  =(       d    U=(       d    U R                  5      $ rS   )r`   is_validtrace_stater   r   s     rA   _is_valid_linkr   k  s-    MW%%L**K8K8K rE   c                   p   \ rS rSrSrSSSSSS\R                  R                  S\" \	R                  5      SSS4S\S\\R                     S\\R                     S\\   S	\R                   S
\\   S\\R&                     S\R                  S\\   S\S\\   S\\   S\\   SS4S jjr\S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S j5       rS r\S 5       r\S\R                  4S j5       r\S\\R                     4S j5       r \S\\   4S j5       r!\S\\   4S j5       r"\S\R                  4S j5       r#\S\R                   4S j5       r$\S\\   4S  j5       r%\S\\R&                     4S! j5       r&\S\4S" j5       r'\\(" S#5      S\\   4S$ j5       5       r)\S\\   4S% j5       r*S-S&\\   4S' jjr+\,S\S\-\\4   4S( j5       r.\,S	\R                   S\\-\\/4      4S) j5       r0\,S
\\   S\1\-\\/4      4S* j5       r2\,S\\R&                     S\1\-\\/4      4S+ j5       r3S,r4g).rU   iq  zProvides read-only access to span attributes.

Users should NOT be creating these objects directly. `ReadableSpan`s are created as
a direct result from using the tracing pipeline via the `Tracer`.

Nr>   r   r   parentresourcer   eventslinkskindinstrumentation_infostatus
start_timeend_timeinstrumentation_scoper<   c                     Xl         X l        Xl        Xl        Xl        X0l        Xl        Xl        XPl        X`l	        Xpl
        Uc  [        R                  " 0 5      U l        OX@l        Xl        g rS   )r   _context_kind_instrumentation_info_instrumentation_scope_parent_start_timer   r   _events_linksr#   create	_resource_status)r@   r   r   r   r   r   r   r   r   r   r   r   r   r   s                 rA   rj   ReadableSpan.__init__y  s_      

%9"&;#%!%%__R0DN%NrE   c                 n    [        U R                  [        5      (       a  U R                  R                  $ gr   r   rK   s    rA   r   ReadableSpan.dropped_attributes  r   rE   c                 n    [        U R                  [        5      (       a  U R                  R                  $ gr   )r   r   r'   r   rK   s    rA   dropped_eventsReadableSpan.dropped_events  s&    dllK00<<'''rE   c                 n    [        U R                  [        5      (       a  U R                  R                  $ gr   )r   r   r'   r   rK   s    rA   dropped_linksReadableSpan.dropped_links  s&    dkk;//;;&&&rE   c                     U R                   $ rS   r   rK   s    rA   r   ReadableSpan.name  r   rE   c                     U R                   $ rS   r   rK   s    rA   get_span_contextReadableSpan.get_span_context      }}rE   c                     U R                   $ rS   r  rK   s    rA   r   ReadableSpan.context  s    }}rE   c                     U R                   $ rS   )r   rK   s    rA   r   ReadableSpan.kind  r   rE   c                     U R                   $ rS   )r   rK   s    rA   r   ReadableSpan.parent      ||rE   c                     U R                   $ rS   )r   rK   s    rA   r   ReadableSpan.start_time  r   rE   c                     U R                   $ rS   r   rK   s    rA   r   ReadableSpan.end_time      ~~rE   c                     U R                   $ rS   )r   rK   s    rA   r   ReadableSpan.status  r  rE   c                 >    [        U R                  =(       d    0 5      $ rS   )r   r   rK   s    rA   r   ReadableSpan.attributes  s     0 0 6B77rE   c                 :    [        S U R                   5       5      $ )Nc              3   $   #    U  H  ov   M     g 7frS   r>   ).0events     rA   	<genexpr>&ReadableSpan.events.<locals>.<genexpr>  s     5uU   )tupler   rK   s    rA   r   ReadableSpan.events  s    5555rE   c                 :    [        S U R                   5       5      $ )Nc              3   $   #    U  H  ov   M     g 7frS   r>   )r$  links     rA   r&  %ReadableSpan.links.<locals>.<genexpr>  s     2kdTkr(  )r)  r   rK   s    rA   r   ReadableSpan.links  s    2dkk222rE   c                     U R                   $ rS   r   rK   s    rA   r   ReadableSpan.resource  r  rE   zFYou should use instrumentation_scope. Deprecated since version 1.11.1.c                     U R                   $ rS   )r   rK   s    rA   r   !ReadableSpan.instrumentation_info  s    
 )))rE   c                     U R                   $ rS   )r   rK   s    rA   r   "ReadableSpan.instrumentation_scope  s    ***rE   indentc                    S nU R                   b-  S[        R                  " U R                   R                  5       3nS nU R                  (       a   [
        R                  " U R                  5      nS nU R                  (       a   [
        R                  " U R                  5      nS[        U R                  R                  R                  5      0nU R                  R                  (       a  U R                  R                  US'   U R                  U R                  (       a  U R                  U R                  5      OS [        U R                   5      UUUUU R#                  U R$                  5      U R'                  U R(                  5      U R+                  U R,                  5      [.        R0                  " U R2                  R5                  5       5      S.n[.        R6                  " XaS9$ )N0xstatus_codedescription)r   r   r   	parent_idr   r   r   r   r   r   r   )r7  )r   	trace_apiformat_span_idspan_idr   r   ns_to_iso_strr   r   r   r:  r   r;  r   r   _format_contextr   _format_attributesr   _format_eventsr   _format_linksr   jsonloadsr   to_jsondumps)r@   r7  r<  r   r   r   f_spans          rA   rG  ReadableSpan.to_json  s`   	;;"Y55dkk6I6IJKLI
++D,<,<=J>>))$..9H 3t||77<<=
 <<##$(LL$<$<F=! JJ7;}}$$T]]3$		N"$ 11$2B2BC))$,,7''4

4==#8#8#:;
  zz&00rE   c                     S[         R                  " U R                  5       3S[         R                  " U R                  5       3[        U R                  5      S.$ )Nr9  )trace_idr?  r   )r=  format_trace_idrL  r>  r?  reprr   r   s    rA   rA  ReadableSpan._format_context  sR     Y66w7G7GHIJI44W__EFG 3 34
 	
rE   c                 L    U b   [        U [        5      (       d  [        U 5      $ U $ rS   )r   dict)r   s    rA   rB  ReadableSpan._format_attributes  s'     !*Z*F*F
##rE   c                     U  Vs/ s HN  nUR                   [        R                  " UR                  5      [        R                  UR                  5      S.PMP     sn$ s  snf )N)r   r   r   )r   r   r@  r   r:   rB  r   )r   r%  s     rA   rC  ReadableSpan._format_events  s_      	
   

!//@"55$$  	
 		
 	
s   AAc                     U  Vs/ s HB  n[         R                  UR                  5      [         R                  UR                  5      S.PMD     sn$ s  snf )Nr   )r:   rA  r   rB  r   )r   r-  s     rA   rD  ReadableSpan._format_links(  s[     

   //LL #55OO	 

 
	
 

s   A	A)r   r   r   r   r   r   r   r   r   r   r   r   r   )   )5rX   rY   rZ   r[   r\   r=  SpanKindINTERNALr0   r1   UNSETr   r   r/   r#   r2   r   r   r   Linkr(   r_   r)   rj   r   r   r  r  r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   rG  staticmethodr	   rA  r   rB  r   rC  rD  ra   r>   rE   rA   rU   rU   q  s    4826'+'+"$*,#,#5#5#>#>>B
 0 01$("&@D )//0 ../	
 8$ $$  	'    '':;  SM 3-  ((<= 
B C  
   
 s  
 c     i((   !6!67    HSM     (3-   	((   8E,, 8 8 6 6 6 3x	/ 3 3 (   P*h/B&C * * +x0D'E + +#1hsm #1J 
 
c3h 
 
 $$	$sCx.	!  

x 

4S#X3G 

 

 
Xinn5 
$tCH~:N 
 
rE   rU   c                       \ rS rSrSrSr        SS\\   S\\   S\\   S\\   S	\\   S
\\   S\\   S\\   4S jjrS r	\
 SS\\   S\S\\   S\\   4S jj5       rSrg)
SpanLimitsi7  a  The limits that should be enforce on recorded data such as events, links, attributes etc.

This class does not enforce any limits itself. It only provides an a way read limits from env,
default values and from user provided arguments.

All limit arguments must be either a non-negative integer, ``None`` or ``SpanLimits.UNSET``.

- All limit arguments are optional.
- If a limit argument is not set, the class will try to read its value from the corresponding
  environment variable.
- If the environment variable is not set, the default value, if any, will be used.

Limit precedence:

- If a model specific limit is set, it will be used.
- Else if the corresponding global limit is set, it will be used.
- Else if the model specific limit has a default value, the default value will be used.
- Else if the global limit has a default value, the default value will be used.

Args:
    max_attributes: Maximum number of attributes that can be added to a span, event, and link.
        Environment variable: OTEL_ATTRIBUTE_COUNT_LIMIT
        Default: {_DEFAULT_ATTRIBUTE_COUNT_LIMIT}
    max_events: Maximum number of events that can be added to a Span.
        Environment variable: OTEL_SPAN_EVENT_COUNT_LIMIT
        Default: {_DEFAULT_SPAN_EVENT_COUNT_LIMIT}
    max_links: Maximum number of links that can be added to a Span.
        Environment variable: OTEL_SPAN_LINK_COUNT_LIMIT
        Default: {_DEFAULT_SPAN_LINK_COUNT_LIMIT}
    max_span_attributes: Maximum number of attributes that can be added to a Span.
        Environment variable: OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT
        Default: {_DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT}
    max_event_attributes: Maximum number of attributes that can be added to an Event.
        Default: {_DEFAULT_OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT}
    max_link_attributes: Maximum number of attributes that can be added to a Link.
        Default: {_DEFAULT_OTEL_LINK_ATTRIBUTE_COUNT_LIMIT}
    max_attribute_length: Maximum length an attribute value can have. Values longer than
        the specified length will be truncated.
    max_span_attribute_length: Maximum length a span attribute value can have. Values longer than
        the specified length will be truncated.
Nmax_attributes
max_events	max_linksmax_span_attributesmax_event_attributesmax_link_attributesmax_attribute_lengthmax_span_attribute_lengthc	                 0   U R                  U[        [        5      U l        U R                  U[        [
        5      U l        U R                  U[        5      n	U	b  U	O[        U l	        U R                  U[        U	b  U	O[        5      U l        U R                  U[        U	b  U	O[        5      U l        U R                  U[         U	b  U	O["        5      U l        U R                  U[&        5      U l        U R                  U[*        U R(                  5      U l        g rS   )_from_env_if_absentr!   $_DEFAULT_OTEL_SPAN_EVENT_COUNT_LIMITra  r"   #_DEFAULT_OTEL_SPAN_LINK_COUNT_LIMITrb  r   #_DEFAULT_OTEL_ATTRIBUTE_COUNT_LIMITr`  r   r   rc  r   )_DEFAULT_OTEL_EVENT_ATTRIBUTE_COUNT_LIMITrd  r   (_DEFAULT_OTEL_LINK_ATTRIBUTE_COUNT_LIMITre  r   rf  r    rg  )
r@   r`  ra  rb  rc  rd  re  rf  rg  global_max_attributess
             rA   rj   SpanLimits.__init__d  s-    22'0

 11&/
 !% 8 86!

 %0 "4 	 $(#;#;+ )4 &=$
  %)$<$< , )4 &>%
! $(#;#;+ )4 &=$
  %)$<$< -%
! *.)A)A%2%%	*
&rE   c                     [        U 5      R                   SU R                   SU R                   SU R                   SU R
                   SU R                   SU R                   SU R                   S3$ )	Nz(max_span_attributes=z, max_events_attributes=z, max_link_attributes=z, max_attributes=z, max_events=z, max_links=z, max_attribute_length=))	typerX   rc  rd  re  r`  ra  rb  rf  rK   s    rA   __repr__SpanLimits.__repr__  s    t*%%&&;D<T<T;UUmnr  oH  oH  nI  I_  `d  `x  `x  _y  yJ  KO  K^  K^  J_  _l  mq  m|  m|  l}  }I  JN  JX  JX  IY  Yp  qu  qJ  qJ  pK  KL  M  	MrE   valueenv_vardefaultr<   c                 l   XR                   :X  a  g SnUcV  U[        ;  a  U$ [        R                  " US5      R                  5       R	                  5       nU[
        :X  a  g  [        U5      nUS:  a  [        UR                  X!5      5      eU$ ! [         a    [        UR                  X%5      5      ef = f)Nz,{} must be a non-negative integer but got {}r5   r   )	rZ  r   getstriplower_ENV_VALUE_UNSETr_   
ValueErrorformat)clsrv  rw  rx  err_msg	str_values         rA   ri  SpanLimits._from_env_if_absent  s     II@ =g%GR0668>>@I,,EI 19W^^G;<<  E !CDDEs   !B %B3)rf  r`  rd  ra  re  rb  rg  rc  )NNNNNNNNrS   )rX   rY   rZ   r[   r\   rZ  r   r_   rj   rt  classmethodr   ri  ra   r>   rE   rA   r^  r^  7  s    (T E )-$(#'-1.2-1.237G
 G
 SMG
 C=	G

 &c]G
 'smG
 &c]G
 'smG
 $,C=G
RM JNSM,/:B3-	# rE   r^  )r`  ra  rb  rc  rd  re  rf  rg  c            !       ,  ^  \ rS rSrSrU 4S jrSSSSSSS\R                  R                  \	" 5       SSS\
S4S\S\R                  S	\\R                     S
\\R                     SSS\\   S\R$                  S\\\      S\\R*                     S\R                  S\	S\\   S\S\S\\   SS4 U 4S jjjrS rS rS\\R*                     4S jrS rS\\\R>                  4   SS4S jr S\S\R>                  SS4S jr!\"S \#SS4S! j5       r$  S:S\S\R$                  S"\\%   SS4S# jjr&\"S$\R*                  SS4S% j5       r' S;S\S\R$                  SS4S& jjr(S\)4S' jr*  S:S(\\%   S)\\+RX                     SS4S* jjr-S;S+\\%   SS4S, jjr.\"S\SS4S- j5       r/S\4S. jr0\" S;S/\1Rd                  \3\44   S0\1R                  \   SS4S1 jj5       r5S2\\6\7      S3\\7   S4\\8   SS4U 4S5 jjr9   S<S6\7S\R$                  S"\\%   S7\SS4
S8 jjr:S9r;U =r<$ )=r:   i  a  See `opentelemetry.trace.Span`.

Users should create `Span` objects via the `Tracer` instead of this
constructor.

Args:
    name: The name of the operation this span represents
    context: The immutable span context
    parent: This span's parent's `opentelemetry.trace.SpanContext`, or
        None if this is a root span
    sampler: The sampler used to create this span
    trace_config: TODO
    resource: Entity producing telemetry
    attributes: The span's attributes to be exported
    events: Timestamped events to be exported
    links: Links to other spans to be exported
    span_processor: `SpanProcessor` to invoke when starting and ending
        this `Span`.
    limits: `SpanLimits` instance that was passed to the `TracerProvider`
c                 J   > U [         L a  [        S5      e[        TU ]  U 5      $ )Nz'Span must be instantiated via a tracer.)r:   	TypeErrorr   __new__)r  r   r   r   s      rA   r  Span.__new__  s%    $;EFFws##rE   Nr>   Tr   r   r   samplertrace_configr   r   r   r   r   rl   r   record_exceptionset_status_on_exceptionr   r<   c           
      |  > Uc  [         R                  " 0 5      n[        TU ]  UUUU
UUUS9  X@l        XPl        Xl        Xl        Xl        Xl	        [        R                  " 5       U l        [        U R                  R                  USU R                  R                  S9U l        U R#                  5       U l        U(       af  U H`  n[        U R                  R&                  UR(                  U R                  R*                  S9Ul        U R$                  R-                  U5        Mb     U R/                  U	5      U l        g )N)r   r   r   r   r   r   r   F)	immutablemax_value_lenr  )r#   r   r   rj   _sampler_trace_config_record_exception_set_status_on_exception_span_processor_limitsrg   rh   ri   r   rc  rg  r   _new_eventsr   rd  r   rf  r   
_new_linksr   )r@   r   r   r   r  r  r   r   r   r   r   rl   r   r  r  limitsr   r%  r   s                     rA   rj   Span.__init__  s   & r*H!5"7 	 	
  )!1(?%-^^%
,LL,,,,@@	
 '')$5LL55$$"&,,"C"C%!
 ##E*   ooe,rE   c                 f    [        U 5      R                   SU R                   SU R                   S3$ )Nz(name="z", context=rr  )rs  rX   r   r   rK   s    rA   rt  Span.__repr__3  s/    t*%%&gdjj\T]]OSTUUrE   c                 @    [        U R                  R                  5      $ rS   )r'   r  ra  rK   s    rA   r  Span._new_events6  s    4<<2233rE   c                    U(       d  [        U R                  R                  5      $ / nU H  nU(       d  M  [        UR                  UR
                  5      (       d  M3  [        U R                  R                  UR
                  U R                  R                  S9Ul	        UR                  U5        M     [         R                  " U R                  R                  U5      $ )Nr  )r'   r  rb  r   r   r   r   re  rf  r   r   from_seq)r@   r   valid_linksr-  s       rA   r  Span._new_links9  s    t||5566Dtt||T__EE#4LL44OO"&,,"C"C$ 
 ""4(  ##DLL$:$:KHHrE   c                     U R                   $ rS   r  rK   s    rA   r  Span.get_span_contextJ  r  rE   c                     U R                      U R                  b  [        R                  S5         S S S 5        g UR	                  5        H  u  p#X0R
                  U'   M     S S S 5        g ! , (       d  f       g = f)Nz Setting attribute on ended span.)ri   r   r   r   itemsr   )r@   r   keyrv  s       rA   set_attributesSpan.set_attributesM  s[     ZZ~~)AB Z
 )..0
(-  % 1 ZZs   $A*'A**
A8r  rv  c                 &    U R                  X05      $ rS   )r  )r@   r  rv  s      rA   set_attributeSpan.set_attributeX  s    ""C<00rE   r%  c                 :    U R                   R                  U5        g rS   )r   r   )r@   r%  s     rA   
_add_eventSpan._add_event[  s    E"rE   r   c                     [        U R                  R                  UU R                  R                  S9nU R	                  [        UUUS95        g )Nr  r   r   r   )r   r  rd  rf  r  r   )r@   r   r   r   s       rA   	add_eventSpan.add_event_  sJ     'LL--,,;;


 	%#	
rE   r-  c                 :    U R                   R                  U5        g rS   )r   r   )r@   r-  s     rA   	_add_linkSpan._add_linkr  s    4 rE   c                     [        X5      (       d  g [        U R                  R                  UU R                  R                  S9nU R                  [        R                  " UUS95        g )Nr  r   )r   r   r  re  rf  r  r=  r[  )r@   r   r   s      rA   add_linkSpan.add_linkv  sY    
 g22&LL,,,,;;


 	NN%	
rE   c                 0   [        U R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  S9$ )N)r   r   r   r   r   r   r   r   r   r   r   r   r   )rU   r   r   r   r   r   r   r   r   r   r   r   r   r   rK   s    rA   _readable_spanSpan._readable_span  sr    MM<<^^''<<++<<''^^!%!;!;"&"="=
 	
rE   r   r;   c                    U R                      U R                  b  [        R                  S5         S S S 5        g Ub  UO	[	        5       U l        S S S 5        U R
                  R                  XS9  g ! , (       d  f       N(= f)Nz"Calling start() on a started span.rv   )ri   r   r   r   r   r  rB   )r@   r   r;   s      rA   start
Span.start  sj    
 ZZ+CD Z
 )4
') 	  	%%d%J Zs   $A0A00
A>r   c                 R   U R                      U R                  c  [        S5      eU R                  b  [        R                  S5         S S S 5        g Ub  UO	[        5       U l        S S S 5        U R                  R                  U R                  5       5        g ! , (       d  f       N8= f)Nz$Calling end() on a not started span.zCalling end() on an ended span.)
ri   r   RuntimeErrorr   r   r   r   r  rH   r  )r@   r   s     rA   endSpan.end  s    ZZ'"#IJJ~~)@A Z *2)=X79DN  	##D$7$7$9: Zs   <BB
B&c                     Xl         g rS   r   )r@   r   s     rA   update_nameSpan.update_name  s    
rE   c                     U R                   S L $ rS   r  rK   s    rA   is_recordingSpan.is_recording  s    ~~%%rE   r   r;  c                    [        U[        5      (       av  U R                  (       a'  U R                  R                  [        R
                  L d  UR                  [        R                  L a  g Ub  [        R                  SU5        Xl        g [        U[        5      (       a]  U R                  (       a'  U R                  R                  [        R
                  L d  U[        R                  L a  g [        X5      U l        g g )NzJDescription %s ignored. Use either `Status` or `(StatusCode, Description)`)	r   r0   r   r:  r1   OKrZ  r   r   )r@   r   r;  s      rA   
set_statusSpan.set_status  s     ff%%LL,,
=%%)9)99&` "L
++LL,,
=Z---!&6DL ,rE   exc_typeexc_valexc_tbc                 &  > Ub}  U R                  5       (       ah  U R                  (       a  U R                  USS9  U R                  (       a6  U R	                  [        [        R                  UR                   SU 3S95        [        TU ])  XU5        g)z3Ends context manager and calls `end` on the `Span`.NT)	exceptionescapedz: )r:  r;  )r  r  r  r  r  r0   r1   ERRORrX   r   __exit__)r@   r  r  r  r   s       rA   r  Span.__exit__  s     4#4#4#6#6 %%%%%F ,,$.$4$4'/'8'8&9G9$E 	F3rE   r  r  c           
         SR                  [        R                  " [        U5      XR                  S95      n[        U5      R
                  n[        U5      R                  nU(       a  US:w  a  U SU 3OUn[        U[        [        U5      [        U[        [        U5      0n	U(       a  U	R                  U5        U R                  SXS9  g)z%Records an exception as a span event.r5   )rv  tbbuiltins.r  r  N)join	tracebackformat_exceptionrs  __traceback__rY   rZ   r-   r+   r   r,   r*   updater  )
r@   r  r   r   r  
stacktracemodulequalnameexception_typer   s
             rA   r  Span.record_exception  s     WW&&Yy5L5L


 i++	?// &J. haz" 	 Ns9~ *s7|	B
 z* 	 	
rE   )r   r   r   r  r   ri   r   r  r  r  r  r   r   r  )NNrS   )NNF)=rX   rY   rZ   r[   r\   r  r=  rX  rY  r7   _UnsetLimitsr   r/   r   r$   Samplerr#   r2   r   r   r   r[  r(   r`   r)   rj   rt  r  r  r  r   AttributeValuer  r  r   r   r  r_   r  r  r  rU   r  r]   r^   r  r  r  r  typingr   r0   r1   r  r   BaseExceptionr   r  r  ra   r   r   s   @rA   r:   r:     s   *$ 37.2!'+'+,0*,#,#5#5#>#>(5>B!%(,@D#5-5- &&5- ../	5-
 (**+5- 5- 8$5- $$5- %)5- 	'5-   5- &5- '':;5- 5- "&5-"  ((<=#5-$ 
%5- 5-nV4I 8 I"	.!#u';';";<	.		.1 1U-A-A 1d 1 #	 #d # # (,#'	

 $$
 C=	

 

& !inn ! ! ! (,

 $$
 
	
(
 
& %)8<KSMK !!4!45K 
	K
;HSM 
;T 
;    &d &  -17VZ/07 __S)7 
	7 7:44./4 -(4 '	4
 
46 (,#'
 
 $$
 C=	

 
 

 
rE   r:   c                       \ rS rSrSrSrg)_Spani  zProtected implementation of `opentelemetry.trace.Span`.

This constructor exists to prevent the instantiation of the `Span` class
by other mechanisms than through the `Tracer`.
r>   N)rX   rY   rZ   r[   r\   ra   r>   rE   rA   r  r    s    rE   r  c                   >   \ rS rSrSrS\R                  S\S\\	\
4   S\S\S\S	\S
S4S jr\S\R$                  R&                  SSSSSS4S\S\\R.                     S\R$                  S\R2                  S\\\R6                        S\\   S\S\S\S
\\R>                     4S jj5       r S\R$                  R&                  SSSSS4S\S\\R.                     S\R$                  S\R2                  S\\\R6                        S\\   S\S\S
\R>                  4S jjr!Sr"g)Traceri  z!See `opentelemetry.trace.Tracer`.r  r   rl   id_generatorr   span_limitsr   r<   Nc                 X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g rS   )r  r   rl   r  r   _span_limitsr   )r@   r  r   rl   r  r   r  r   s           rA   rj   Tracer.__init__   s,      ,($8!'&;#rE   r>   Tr   r   r   r   r   r   r  r  end_on_exitc
              #      #    U R                  UUUUUUUUS9n
[        R                  " U
U	UUS9 n
U
v   S S S 5        g ! , (       d  f       g = f7f)N)r   r   r   r   r   r   r  r  )r  r  r  )
start_spanr=  use_span)r@   r   r   r   r   r   r   r  r  r  r9   s              rA   start_as_current_spanTracer.start_as_current_span4  sg      !!-$;  	
 #-$;	

 J
 
 
s   .A>	A
AAc	                 "   [         R                  " U5      R                  5       n	U	b*  [        U	[         R                  5      (       d  [        S5      eU	b  U	R                  (       d  S n	U R                  R                  5       n
OU	R                  n
U R                  R                  X*XXE5      nUR                  R                  5       (       a.  [         R                  " [         R                  R                  5      O-[         R                  " [         R                  R                   5      n[         R                  " U
U R                  R#                  5       SUUR$                  S9nUR                  R'                  5       (       a{  [)        UUU	U R                  U R*                  UR,                  R/                  5       U R0                  UUU R2                  UUU R4                  U R6                  S9nUR9                  XbS9  U$ [         R:                  " US9nU$ )Nz2parent_span_context must be a SpanContext or None.F)	is_remotetrace_flagsr   )r   r   r   r  r   r   rl   r   r   r   r  r  r  r   )r   r;   r   )r=  get_current_spanr  r   r/   r  r   r  generate_trace_idrL  r  should_sampledecision
is_sampled
TraceFlagsSAMPLEDDEFAULTgenerate_span_idr   r  r  r   r   copyrl   r   r  r   r  NonRecordingSpan)r@   r   r   r   r   r   r   r  r  parent_span_contextrL  sampling_resultr  span_contextr9   s                  rA   r  Tracer.start_spanS  s    (88



 	 *:!6!64
 4
 D 
 &.A.J.J"&((::<H*33H ,,44t:
 ''2244   !5!5!=!=>%%i&:&:&B&BC 	
 !,,..0#'33
 ##0022$**55::<#22%)%>%>!1(?((&*&A&AD  JJ*JE  --lCDrE   )r   r  r  r   r   r  rl   )#rX   rY   rZ   r[   r\   r$   r  r#   r   rc   r   r%   r(   r^  r)   rj   r3   r=  rX  rY  r   r   r]   r^   r2   r   r   r[  r_   r`   r
   r:   r  r  ra   r>   rE   rA   r  r    s   +<!!< < )+GG
	< "< 2<  <  4< 
<(  26#,#5#5#>#>'+46$(!%(,  +--.   	
 $$ 01 SM  "&  
)..	! B 26#,#5#5#>#>'+46$(!%(,JJ +--.J   	J
 $$J 01J SMJ J "&J 
J JrE   r  c                   Z   \ rS rSrSr      SS\\R                     S\\   S\	S\
\\S4   S\\   S	\\   S
S4S jjr\S
\4S j5       r   SS\S\R
                  \   S\R
                  \   S\R
                  \R*                     S
S4
S jjrS\S
S4S jrSS jrSS\S
\	4S jjrSrg)TracerProvideri  z)See `opentelemetry.trace.TracerProvider`.Nr  r   shutdown_on_exitactive_span_processorr  r  r<   c                    U=(       d
    [        5       U l        Uc  [        5       U l        OXPl        Uc  [        R
                  " 0 5      U l        OX l        U(       d  [        R                  " 5       nXl	        U=(       d
    [        5       U l        [        R                  " [        S5      nUR                  5       R!                  5       S:H  U l        S U l        U(       a&  [&        R(                  " U R*                  5      U l        g g )Nr5   true)rc   _active_span_processorr&   r  r#   r   r   r$   _get_from_env_or_defaultr  r^  r  r   rz  r   r|  r{  	_disabled_atexit_handleratexitregisterrL   )r@   r  r   r  r  r  r  disableds           rA   rj   TracerProvider.__init__  s     "D%B%D 	#  1 3D ,%__R0DN%N779G'7:<;;0"5!)//1V;##)??4==#AD  rE   c                     U R                   $ rS   r1  rK   s    rA   r   TracerProvider.resource  r  rE   instrumenting_module_nameinstrumenting_library_version
schema_urlr   ztrace_api.Tracerc                 V   U R                   (       a
  [        5       $ U(       d  Sn[        R                  S5        Uc  Sn[	        SS[
        SS9  [        UUU5      n[        U R                  U R                  U R                  U R                  UU R                  [        UUUU5      5      $ )Nr5   z+get_tracer called with missing module name.ignorezEYou should use InstrumentationScope. Deprecated since version 1.11.1.zopentelemetry.sdk.trace)messagecategoryr  )r  r.   r   errorr   DeprecationWarningr(   r  r  r   r  r  r  r)   )r@   r  r  r  r   r   s         rA   
get_tracerTracerProvider.get_tracer  s     >><((*%LLFG(0,.)X',	
  3%) 
 LLMM''  )-	
 	
rE   rl   c                 :    U R                   R                  U5        g)zRegisters a new :class:`SpanProcessor` for this `TracerProvider`.

The span processors are invoked in the same order they are registered.
N)r  rq   rp   s     rA   rq   !TracerProvider.add_span_processor  s     	##66~FrE   c                     U R                   R                  5         U R                  b(  [        R                  " U R                  5        SU l        gg)z;Shut down the span processors added to the tracer provider.N)r  rL   r  r  
unregisterrK   s    rA   rL   TracerProvider.shutdown  sA    ##,,.+d223#'D  ,rE   rN   c                 8    U R                   R                  U5      $ )ag  Requests the active span processor to process all spans that have not
yet been processed.

By default force flush is called sequentially on all added span
processors. This means that span processors further back in the list
have less time to flush their spans.
To have span processors flush their spans in parallel it is possible to
initialize the tracer provider with an instance of
`ConcurrentMultiSpanProcessor` at the cost of using multiple threads.

Args:
    timeout_millis: The maximum amount of time to wait for spans to be
        processed.

Returns:
    False if the timeout is exceeded, True otherwise.
)r  rQ   rP   s     rA   rQ   TracerProvider.force_flush  s    $ **66~FFrE   )r  r  r  r   r  r  r  )NNTNNN)NNNrV   rW   )rX   rY   rZ   r[   r\   r   r$   r  r#   r`   r   rc   r   r%   r^  rj   r   r   r   r  r2   r   r%  r7   rq   rL   r_   rQ   ra   r>   rE   rA   r  r    sL   3 /3'+!% .2,0B(**+B 8$B 	B
  %)+GM 
B {+B j)B 
BB (   ?C+/8<+
#&+
 (.s';+
 OOC(	+

 OOE$4$45+
 
+
ZG G4 G(G# G$ G GrE   r  )kr   r  concurrent.futuresr   rE  loggingrg   r  r  osr   timer   r2   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   warningsr   typing_extensionsr   opentelemetryr   r]   r   r=  opentelemetry.attributesr   opentelemetry.sdkr   'opentelemetry.sdk.environment_variablesr   r   r   r   r   r   r    r!   r"   opentelemetry.sdk.resourcesr#   opentelemetry.sdk.tracer$   $opentelemetry.sdk.trace.id_generatorr%   r&   opentelemetry.sdk.utilr'   &opentelemetry.sdk.util.instrumentationr(   r)   5opentelemetry.semconv.attributes.exception_attributesr*   r+   r,   r-   opentelemetry.tracer.   r/   opentelemetry.trace.statusr0   r1   opentelemetry.utilopentelemetry.util._decoratorr3   	getLoggerrX   r   rl  r   rm  rn  rj  rk  r}  r7   rc   r   ABCr   r   r   r   r`   r   rU   r^  rZ  r  ri  SPAN_ATTRIBUTE_COUNT_LIMITr:   r  r  r  r>   rE   rA   <module>rE     s              1    $ ( 0 , 6 "
 
 
 1 , O .  8 9 $ A			8	$&) #+. (,/ )+. ('* $&) #  / /h=M =@S= Sl ,I @K U5E5E $ C
 C
LS Sl ##"((#))"((#))(..	 (;;#, r
9>>< r
j	D @Y @FxGY-- xGrE   