
    _DiT                         S r  " S S5      rg)z:Middleware for making it easier to do distributed tracing.c                   ,    \ rS rSrSrS rS\4S jrSrg)TracingMiddleware   a?  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                 (    SSK Jn  X l        Xl        g)zInitialize the middleware.    )tracing_contextN)langsmith.run_helpersr   _with_headersapp)selfr
   r   s      \/var/www/html/Aiprofessor/professorTrac/lib/python3.13/site-packages/langsmith/middleware.py__init__TracingMiddleware.__init__   s    9,    scopec                   #    US   S:X  aM  SU;   aG  [        US   5      nSU;   a3  U R                  US9   U R                  XU5      I Sh  vN   SSS5        gU R                  XU5      I Sh  vN   g N(! , (       d  f       g= f N7f)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__TracingMiddleware.__call__   s      =F"yE'95+,G!W,''w'7((54888 8hhut,,, 9 87,s:   3B	A6A4A6B	.B/B	4A66
B B	)r	   r
   N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__ r   r   r   r      s    	-D -r   r   N)r   r   r!   r   r   <module>r"      s    @&- &-r   