
    JiB                         U d dl Z d dlmZ d dlmZmZ ddlmZmZm	Z	 ddl
mZ ddlmZ  ed e       g e       gd	
      Zeed<    e	e      Ze	ed<   ddedefdZ G d de      Zy)    N)ABC)AnyList   )DISPATCHER_SPAN_DECORATED_ATTR
DispatcherManager)NullEventHandler)NullSpanHandlerrootF)nameevent_handlersspan_handlers	propagateroot_dispatcherroot_managerr   returnc                 0   | t         j                  v rt         j                  |    S dj                  | j                  d      dd       }|t         j                  v r|}nd}t	        | t
        j                  |t               }t         j                  |       |S )z@Module method that should be used for creating a new Dispatcher..Nr   )r   	root_nameparent_namemanager)r   dispatchersjoinsplitr   r   r   add_dispatcher)r   candidate_parent_namer   new_dispatchers       v/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/llama_index_instrumentation/__init__.pyget_dispatcherr!      s    |'''''--HHTZZ_Sb%9: 8 88+!&&	N /    c                   ,     e Zd ZdZdeddf fdZ xZS )DispatcherSpanMixina	  
    Apply the `dispatcher.span` decorator to implementations of abstract methods, as well
    as any methods previously decorated (in any base class) that are being overridden by
    a subclass. For example, if class `A` has abstract method `f`, and class `B` inherits
    from `A` and provides an implementation of `f`, then `B.f` will be decorated by the mixin.
    Furthermore, if `B` has a non-abstract method `g` that is decorated by `dispatcher.span`
    and new class `C` inherits from `B` and overrides `g`, then `C.g` will also be decorated
    by the mixin. Note that users can still manually apply `dispatcher.span` to the methods
    in their custom subclasses without creating duplicate spans because the `dispatcher.span`
    decorator should be idempotent.
    kwargsr   Nc                 ^   t        |   di | g }g }t        j                  |       D ]  }|| u r|j                  j                         D ]]  \  }}t        |      st        |d      r|j                  r|j                  |       <t        |t              sM|j                  |       _  t        | j                        }| j                  j                         D ]N  \  }}t        |      rt        |d      r|j                  r*||v s||v s3t        | ||j                  |             P y )N__isabstractmethod__ )super__init_subclass__inspectgetmro__dict__itemscallablehasattrr'   appendr   r!   
__module__setattrspan)	clsr%   abstract_methodsdecorated_methodsbase_clsattrmethod
dispatcher	__class__s	           r    r*   z%DispatcherSpanMixin.__init_subclass__9   s   !+F+&(')s+ 	3H3 ( 1 1 7 7 9 	3f'F$:;33$++D1V%CD%,,T2	3	3 $CNN3
LL..0 	<LD&V$6#9://''43D+DT:??6#:;	<r"   )__name__r2   __qualname____doc__r   r*   __classcell__)r<   s   @r    r$   r$   ,   s     
< < < <r"   r$   )r   )r+   abcr   typingr   r   r;   r   r   r	   r   r
   r   r   r   __annotations__r   strr!   r$   r(   r"   r    <module>rE      sy       
 - *(	$&'"$%	   0g 0 * *'<# '<r"   