Ë
    ³ŒjT  ã                   ó   — d Z  G d„ d«      Zy)z:Middleware for making it easier to do distributed tracing.c                   ó"   — e Zd ZdZd„ Zdefd„Zy)ÚTracingMiddlewareaW  Middleware for propagating distributed tracing context using LangSmith.

    This middleware checks for the `'langsmith-trace'` header and propagates the
    tracing context if present. It does not start new traces by default.

    Designed to work with ASGI applications.

    Attributes:
        app: The ASGI application being wrapped.
    c                 ó,   — ddl m} || _        || _        y)zInitialize the middleware.é    )Útracing_contextN)Úlangsmith.run_helpersr   Ú_with_headersÚapp)Úselfr	   r   s      ú^/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langsmith/middleware.pyÚ__init__zTracingMiddleware.__init__   s   € å9à,ˆÔØˆ�ó    Úscopec              ƒ   ó  K  — |d   dk(  rMd|v rIt        |d   «      }d|v r7| j                  |¬«      5  | j                  |||«      ƒ d{  –—†  ddd«       y| j                  |||«      ƒ d{  –—†  y7 Œ)# 1 sw Y   yxY w7 Œ­w)a*  Handle incoming requests and propagate tracing context if applicable.

        Args:
            scope: A dict containing ASGI connection scope.
            receive (callable): An awaitable callable for receiving ASGI events.
            send (callable): An awaitable callable for sending ASGI events.

        If the request is HTTP and contains the `'langsmith-trace'` header,
        it propagates the tracing context before calling the wrapped application.

        Otherwise, it calls the application directly without modifying the context.
        ÚtypeÚhttpÚheaderss   langsmith-trace)ÚparentN)Údictr   r	   )r
   r   ÚreceiveÚsendr   s        r   Ú__call__zTracingMiddleware.__call__   s‰   è ø€ ð �‰=˜FÒ" y°EÑ'9Ü˜5 Ñ+Ó,ˆGØ! WÑ,Ø×'Ñ'¨wÐ'Õ7ØŸ(™( 5¨'°4Ó8×8Ð8÷ 8àØ�h‰h�u˜g tÓ,×,Ñ,ð 9ø÷ 8àúØ,ús:   ‚1B³A6Á
A4ÁA6ÁBÁ.BÁ/BÁ4A6Á6A?Á;BN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r   r   r   r      s   „ ñ	òð- Dô -r   r   N)r   r   r   r   r   Ú<module>r      s   ðÙ @÷&-ò &-r   