
    i_                         d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ e	 	 ddeded	ed
edz  dedz  deeddf   fd       ZdgZy)zClient-side telemetry helpers.    )	Generator)contextmanager)SpanSpanKindStatus
StatusCode)
get_tracerNnamemethodcomponent_key
session_idresource_urireturnc              #   z  K   t               }|j                  | t        j                        5 }d|||d}|r||d<   |r||d<   |j	                  |       	 | 	 ddd       y# t
        $ r?}|j                  |       |j                  t        t        j                                d}~ww xY w# 1 sw Y   yxY ww)zCreate a CLIENT span with standard MCP attributes.

    Automatically records any exception on the span and sets error status.
    )kindmcp)z
rpc.systemz
rpc.methodzmcp.method.namezfastmcp.component.keyzmcp.session.idzmcp.resource.uriN)r	   start_as_current_spanr   CLIENTset_attributes	Exceptionrecord_exception
set_statusr   r   ERROR)	r
   r   r   r   r   tracerspanattrses	            h/Users/bowang/.openclaw/workspace/ChatDev/.venv/lib/python3.12/site-packages/fastmcp/client/telemetry.pyclient_spanr      s      \F		%	%d	%	AT   %%2!
 &0E"#(4E$%E"	J! 
B	A"  	!!!$OOF:#3#345	# 
B	As:   ,B;'B/A$	B;$	B,-:B''B,,B//B84B;r   )NN)__doc__collections.abcr   
contextlibr   opentelemetry.tracer   r   r   r   fastmcp.telemetryr	   strr   __all__     r   <module>r)      s    $ % % B B ( 
 "# 
     d
	 
 *  tT4    F /r(   