
    KiR                     ~    S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	J
r
  S SKJr   " S S\R                  5      rg)	    N)trace)Context)textmap)format_span_idformat_trace_id)
TraceStatec            	          \ rS rSrSrSrSrSr\R                  " \5      r
S\R                  4S\R                  S\R                  \   S	\R"                  \R                     S
\4S jjrS\R&                  4S\R                  S\R                  \   S\R(                  \R                     S
S4S jjr\S
\R.                  \   4S j5       rSrg)TraceContextTextMapPropagator   z6Extracts and injects using w3c TraceContext's headers.traceparent
tracestatezK^[ 	]*([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?[ 	]*$Ncarriercontextgetterreturnc                    Uc
  [        5       nUR                  XR                  5      nU(       d  U$ [        R                  " U R
                  US   5      nU(       d  U$ UR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      n	US:X  d  US:X  a  U$ US	:X  a  UR                  S
5      (       a  U$ US:X  a  U$ UR                  XR                  5      n
U
c  SnO[        R                  " U
5      n[        R                  " [        US5      [        US5      S[        R                  " [        U	S5      5      US9n[        R                  " [        R                  " U5      U5      $ )zjExtracts SpanContext from the carrier.

See `opentelemetry.propagators.textmap.TextMapPropagator.extract`
Nr                00000000000000000000000000000000000000000000000000   ff   T)trace_idspan_id	is_remotetrace_flagstrace_state)r   get_TRACEPARENT_HEADER_NAMEresearch_TRACEPARENT_HEADER_FORMAT_REgroup_TRACESTATE_HEADER_NAMEr   from_headerr   SpanContextint
TraceFlagsset_span_in_contextNonRecordingSpan)selfr   r   r   headermatchversionr   r   r    tracestate_headersr   span_contexts                n/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/opentelemetry/trace/propagation/tracecontext.pyextract%TraceContextTextMapPropagator.extract$   sP    ?iGG%B%BCN		$<<fQiHN{{1~A{{1~ ;;q>x7h#6Nd?{{1~~d?N#ZZ1M1MN%J#//0BCJ((2&$(([")=>"
 ((""<0'
 	
    setterc                    [         R                  " U5      nUR                  5       nU[         R                  :X  a  gS[	        UR
                  5       S[        UR                  5       SUR                  S 3nUR                  XR                  U5        UR                  (       a7  UR                  R                  5       nUR                  XR                  U5        gg)zhInjects SpanContext into the carrier.

See `opentelemetry.propagators.textmap.TextMapPropagator.inject`
Nz00--02x)r   get_current_spanget_span_contextINVALID_SPAN_CONTEXTr   r   r   r   r    setr#   r!   	to_headerr(   )r/   r   r   r9   spanr4   traceparent_stringtracestate_strings           r5   inject$TraceContextTextMapPropagator.injectY   s     %%g.,,.5555"?<3H3H#I"J!N[g[o[oLpKqqrs  tL  tL  MP  sQ  R

799;MN## , 8 8 B B DJJ557H $r8   c                 2    U R                   U R                  1$ )zqReturns a set with the fields set in `inject`.

See
`opentelemetry.propagators.textmap.TextMapPropagator.fields`
)r#   r(   )r/   s    r5   fields$TraceContextTextMapPropagator.fieldso   s     --t/K/KLLr8    )__name__
__module____qualname____firstlineno____doc__r#   r(   _TRACEPARENT_HEADER_FORMATr$   compiler&   r   default_getterCarrierTtypingOptionalr   Getterr6   default_setterSetterrE   propertySetstrrH   __static_attributes__rJ   r8   r5   r
   r
      s   @,*	  %'JJ/I$J!
 -13:3I3I	3
!!3
 )3
 w//0	3

 
3
p -13:3I3I	!! ) w//0	
 
, M

3 M Mr8   r
   )r$   rT   opentelemetryr   opentelemetry.context.contextr   opentelemetry.propagatorsr   opentelemetry.tracer   r   opentelemetry.trace.spanr   TextMapPropagatorr
   rJ   r8   r5   <module>rc      s2    
   1 - ? /]MG$=$= ]Mr8   