HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/.local/lib/python3.10/site-packages/langsmith/__pycache__/middleware.cpython-310.pyc
o

���g>�@sdZGdd�d�ZdS)z:Middleware for making it easier to do distributed tracing.c@s&eZdZdZdd�Zdefdd�ZdS)�TracingMiddlewareaZMiddleware 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.
    It is designed to work with ASGI applications.

    Attributes:
        app: The ASGI application being wrapped.
    cCsddlm}||_||_dS)zInitialize the middleware.�)�tracing_contextN)�langsmith.run_helpersr�
_with_headers�app)�selfrr�r�G/home/arjun/.local/lib/python3.10/site-packages/langsmith/middleware.py�__init__s
zTracingMiddleware.__init__�scopec�s��|ddkr8d|vr8t|d�}d|vr8|j|d��|�|||�IdHWd�dS1s1wYdS|�|||�IdHdS)aHandle incoming requests and propagate tracing context if applicable.

        Args:
            scope: A dict containing ASGI connection scope.
            receive: An awaitable callable for receiving ASGI events.
            send: 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�headersslangsmith-trace)�parentN)�dictrr)rr�receive�sendrrrr	�__call__s�
��zTracingMiddleware.__call__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrr	rs
rN)rrrrrr	�<module>s