Ë
    `QêjŸ  ã            	       óx  — U d 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e«      Zdej                  fdej                  d	edz  d
ej                   ej                     defd„Zdej$                  fdej                  d	edz  dej&                  ej                     ddfd„Zdej*                  fd„Z e«       aej*                  ed<   g Zeej*                     ed<    ej6                  ed«      Zej;                  d«      D ]  Zej?                  «       ZŒ dej*                  fd„Z dej*                  ddfd„Z!y)aÿ  
API for propagation of context.

The propagators for the
``opentelemetry.propagators.composite.CompositePropagator`` can be defined
via configuration in the ``OTEL_PROPAGATORS`` environment variable. This
variable should be set to a comma-separated string of names of values for the
``opentelemetry_propagator`` entry point. For example, setting
``OTEL_PROPAGATORS`` to ``tracecontext,baggage`` (which is the default value)
would instantiate
``opentelemetry.propagators.composite.CompositePropagator`` with 2
propagators, one of type
``opentelemetry.trace.propagation.tracecontext.TraceContextTextMapPropagator``
and other of type ``opentelemetry.baggage.propagation.W3CBaggagePropagator``.
Notice that these propagator classes are defined as
``opentelemetry_propagator`` entry points in the ``pyproject.toml`` file of
``opentelemetry``.

Example::

    import flask
    import requests
    from opentelemetry import propagate


    PROPAGATOR = propagate.get_global_textmap()


    def get_header_from_flask_request(request, key):
        return request.headers.get_all(key)


    def set_header_into_requests_request(request: requests.Request, key: str, value: str):
        request.headers[key] = value


    def example_route():
        context = PROPAGATOR.extract(get_header_from_flask_request, flask.request)
        request_to_downstream = requests.Request("GET", "http://httpbin.org/get")
        PROPAGATOR.inject(
            set_header_into_requests_request,
            request_to_downstream,
            context=context,
        )
        session = requests.Session()
        session.send(request_to_downstream.prepare())


.. _Propagation API Specification:
    https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md
é    )Ú	getLogger)Úenviron)ÚContext)ÚOTEL_PROPAGATORS)Ú	compositeÚtextmapNÚcarrierÚcontextÚgetterÚreturnc                 ó:   — t        «       j                  | ||¬«      S )aZ  Uses the configured propagator to extract a Context from the carrier.

    Args:
        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.
        carrier: and 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: an optional Context to use. Defaults to root
            context if not set.
    )r   )Úget_global_textmapÚextract)r	   r
   r   s      úe/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/opentelemetry/propagate/__init__.pyr   r   B   s   € ô$ Ó×'Ñ'¨°ÀÐ'ÓHÐHó    Úsetterc                 ó<   — t        «       j                  | ||¬«       y)aç  Uses the configured propagator to inject a Context into the carrier.

    Args:
        carrier: the medium used by Propagators to read
            values from and write values to.
            Should be paired with setter, which
            should know how to set header values on the carrier.
        context: An optional Context to use. Defaults to current
            context if not set.
        setter: An optional `Setter` object that can set values
            on the carrier.
    )r
   r   N)r   Úinject)r	   r
   r   s      r   r   r   W   s   € ô" Ó×Ñ °ÀÐÕHr   c                  óŠ  — t        j                  t        «      } | s-ddlm} ddlm} t        j                   |«        |«       g«      S ddl	m
} g }| j                  d«      D ]�  }|j                  «       }|j                  «       dk(  r,t        j                  d«       t        j                  g «      c S 	 |j!                   t#        t%         |d|¬	«      «      «      j'                  «       «       «       Œ’ t        j                  |«      S # t(        $ r t+        d
|› d�«      ‚t,        $ r t        j/                  d|«       ‚ w xY w)Nr   )ÚW3CBaggagePropagator)ÚTraceContextTextMapPropagator)Úentry_pointsú,ÚnonezMOTEL_PROPAGATORS environment variable contains none, removing all propagatorsÚopentelemetry_propagator)ÚgroupÚnamezPropagator z5 not found. It is either misspelled or not installed.zFailed to load propagator: %s)r   Úgetr   Ú!opentelemetry.baggage.propagationr   Ú,opentelemetry.trace.propagation.tracecontextr   r   ÚCompositePropagatorÚ&opentelemetry.util._importlib_metadatar   ÚsplitÚstripÚlowerÚloggerÚdebugÚappendÚnextÚiterÚloadÚStopIterationÚ
ValueErrorÚ	ExceptionÚ	exception)Ú
configuredr   r   r   Ú_propagatorsÚ_propagators         r   Ú_load_propagatorsr3   k   s:  € Ü—‘Ô-Ó.€JÙõ	
õ
	
ô ×,Ñ,Ñ.KÓ.MÑOcÓOeÐ-fÓgÐgõð 57€LØ!×'Ñ'¨Ó,ò ˆØ!×'Ñ'Ó)ˆØ×ÑÓ &Ò(Ü�L‰LÐhÔiÜ×0Ñ0°Ó4Ò4ð	Ø×Ñð”ÜÙ$Ø"<Ø!,ôóó÷ ‘$“&óõ	ðô* ×(Ñ(¨Ó6Ð6øô ò 	oÜ˜{¨;¨-Ð7lÐmÓnÐnÜò 	Ü×ÑÐ<¸kÔJØð	ús   Â5>D
Ä
8EÚ_HTTP_TEXT_FORMATÚpropagatorsztracecontext,baggager   c                  ó   — t         S ©N©r4   © r   r   r   r   £   s   € ÜÐr   Úhttp_text_formatc                 ó   — | a y r7   r8   )r:   s    r   Úset_global_textmapr<   §   s
   € ð )Ñr   )"Ú__doc__Úloggingr   Úosr   Úopentelemetry.context.contextr   Ú#opentelemetry.environment_variablesr   Úopentelemetry.propagatorsr   r   Ú__name__r&   Údefault_getterÚCarrierTÚGetterr   Údefault_setterÚSetterr   ÚTextMapPropagatorr3   r4   Ú__annotations__r5   Úlistr   Úenviron_propagatorsr#   Ú
propagatorr$   r   r<   r9   r   r   ú<module>rN      s{  ðò2õh Ý å 1Ý @ß 8á	�8Ó	€ð
 #Ø/6×/EÑ/EñIØ×ÑðIà�t‰^ðIð �N‰N˜7×+Ñ+Ñ,ðIð ó	Ið. #Ø/6×/EÑ/EñIØ×ÑðIà�t‰^ðIð �N‰N˜7×+Ñ+Ñ,ðIð 
ó	Ið(*7˜7×4Ñ4ó *7ñZ 0AÓ/BÐ �7×,Ñ,Ó Bð 02€ˆT�'×+Ñ+Ñ,Ó 1à!�g—k‘kÐ"2Ð4JÓKÐ à%×+Ñ+¨CÓ0ò $€JØ×!Ñ!Ó#�Jð$ð˜G×5Ñ5ó ð)Ø×/Ñ/ð)à	ô)r   