
    $Ii}                        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  S SKJr  S SKJrJr  S SKJrJr  S S	KJr  S S
KJr  S SKJr  \" 5       rSr S"S\S\\   S\
\\4   S\
\\4   4S jjr   S#S\!S\"S\"S\4S jjr#S\\$\4   S\4S jr% S"S jr&S\4S jr'S\(4S jr)S r*S\"4S jr+S\"4S jr,\S\S\S   4S j5       r-\S\S   4S  j5       r.\S\S   4S! j5       r/g)$    N)contextmanager)import_module)escapesub)DictIterableSequenceUnion)ObjectProxy)contexttrace)"_SUPPRESS_HTTP_INSTRUMENTATION_KEY_SUPPRESS_INSTRUMENTATION_KEY)extract)
StatusCode)TraceContextTextMapPropagatorsuppress_instrumentationobj
attributesexistingreturnc                     0 nU(       a  UR                  U5        U H!  n[        XS 5      nUc  M  [        U5      X4'   M#     U$ N)updategetattrstr)r   r   r   	extractedattrvalues         I/venv/lib/python3.13/site-packages/opentelemetry/instrumentation/utils.pyextract_attributes_from_objectr!   .   sI     I"4(!%jIO      statusallow_redirectserver_spanc                 8   [        U [        5      (       d  [        R                  $ U S:  a  [        R                  $ U S::  a  [        R                  $ U S::  a  U(       a  [        R                  $ U S::  a  U(       a  [        R                  $ [        R                  $ )zqConverts an HTTP status code to an OpenTelemetry canonical status code

Args:
    status (int): HTTP status code
d   i+  i  i  )
isinstanceintr   UNSETERROR)r#   r$   r%   s      r    http_status_to_status_coder,   ;   sy     fc""|}}}r"   r   c                    [        U [        5      (       a,   U R                  SS5      u  p#[        U5      n [        XS5      n [        XS5      nU(       a?  [        U[        5      (       a)  [        US	5      (       a  [        XUR                  5        gggg! [         a  n[	        SU  S35      UeSnAff = f! [         a  n[	        SU SU S35      UeSnAff = f)
a9  Given a function that was wrapped by wrapt.wrap_function_wrapper, unwrap it

The object containing the function to unwrap may be passed as dotted module path string.

Args:
    obj: Object that holds a reference to the wrapped function or dotted import path as string
    attr (str): Name of the wrapped function
.   zCannot parse 'z' as dotted import pathNzCannot import 'z' from ''__wrapped__)r(   r   rsplit
ValueErrorImportErrorr   r   AttributeErrorr   hasattrsetattrr1   )r   r   module_path
class_nameexcmodulefuncs          r    unwrapr=   T   s     #s	&)jja&8#K
 {+	&-C 3d#D
4--'$2N2N4++, 3O-t  	 %<=	  	!*XfXQ?	s.   B B7 
B4B//B47
CCCc                 V   S=n=px[         R                  " 5       [         R                  L a:  [        X4S9n[        R
                  " U5      n[         R                  R                  nO/[        R                  " 5       n[         R                  R                  nU R                  UUUUUS9n	X4$ )a  Returns internal or server span along with the token which can be used by caller to reset context


Args:
    tracer : tracer in use by given instrumentation library
    span_name (string): name of the span
    start_time : start time of the span
    context_carrier : object which contains values that are
        used to construct a Context. This object
        must be paired with an appropriate getter
        which understands how to extract a value from it.
    context_getter : an object which contains a get function that can retrieve zero
        or more values from the carrier and a keys function that can get all the keys
        from carrier.
N)getter)namer   kind
start_timer   )r   get_current_spanINVALID_SPANr   r   attachSpanKindSERVERget_currentINTERNAL
start_span)
tracer	span_namerB   context_carriercontext_getterr   tokenctx	span_kindspans
             r    _start_internal_or_server_spanrS   q   s    0 #"E"C5#5#55o=s#NN))	!!#NN++	  D ;r"   c                     [        U [        [        45      (       d  U $ [        R                  R                  U 5      nUR                  SS5      $ )N%z%%)r(   r   bytesurllibparsequotereplace)squoteds     r    
_url_quoter]      s?    a#u&&\\"F
 >>#t$$r"   c                  4    0 n [         R                  U 5        U $ )zg
Return the OpenTelemetry Trace and Span IDs if Span ID is set in the
OpenTelemetry execution context.
)
propagatorinject)_headerss    r    _get_opentelemetry_valuesrb      s     HhOr"   c                 8    [        [        U5       U S3SU 5      $ )Nz(?!$) )r   r   )python_path	directorypath_separators      r    _python_path_without_directoryrh      s*    9~.e4
 r"   c                      [         R                  " [        5      =(       d    [         R                  " [        5      (       + $ r   )r   	get_valuer   #_SUPPRESS_INSTRUMENTATION_KEY_PLAIN r"   r    is_instrumentation_enabledrm      s0    78 	B@A r"   c                  b    [        5       =(       a    [        R                  " [        5      (       + $ r   )rm   r   rj   r   rl   r"   r    is_http_instrumentation_enabledro      s'    %' 0A0A*1 - r"   keysc               '     #    [         R                  " 5       nU  H  n[         R                  " USU5      nM     [         R                  " U5      n Sv   [         R                  " U5        g! [         R                  " U5        f = f7f),Suppress instrumentation within the context.TN)r   rH   	set_valuerE   detach)rp   rP   keyrO   s       r    _suppress_instrumentationrv      sa      


CT3/ NN3Euus   ABA+ B+BBc               #   p   #    [        [        [        5         Sv   SSS5        g! , (       d  f       g= f7frr   N)rv   r   rk   rl   r"   r    r   r      s)      
#%'J
 	
 
 
s   6%	6
36c               #   f   #    [        [        5         Sv   SSS5        g! , (       d  f       g= f7frx   )rv   r   rl   r"   r    suppress_http_instrumentationrz      s      
##E	F 
G	F	Fs   1 	1
.1r   )TF)0urllib.parserW   
contextlibr   	importlibr   rer   r   typingr   r   r	   r
   wraptr   opentelemetryr   r   opentelemetry.contextr   r   opentelemetry.propagater   opentelemetry.tracer   ,opentelemetry.trace.propagation.tracecontextr   r_   rk   anyr   r!   r)   boolr,   objectr=   rS   r]   dictrb   rh   rm   ro   rv   r   rz   rl   r"   r    <module>r      sw    % #  2 2  ( , * +,
  $ EI
	
"3-
37S>
	#s(^
    	2-fck" -# -F 'T%S %4 D   	S 	Xd^ 	 	 (4.   x~  r"   