Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Creating traces/spans

trace

trace(workflow_name:str,trace_id:str|None=None,group_id:str|None=None,metadata:dict[str,Any]|None=None,disabled:bool=False,)->Trace

Create a new trace. The trace will not be started automatically; you should either useit as a context manager (with trace(...):) or calltrace.start() +trace.finish()manually.

In addition to the workflow name and optional grouping identifier, you can providean arbitrary metadata dictionary to attach additional user-defined information tothe trace.

Parameters:

NameTypeDescriptionDefault
workflow_namestr

The name of the logical app or workflow. For example, you might provide"code_bot" for a coding agent, or "customer_support_agent" for a customer support agent.

required
trace_idstr | None

The ID of the trace. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_trace_id() to generate a trace ID, to guarantee that IDs arecorrectly formatted.

None
group_idstr | None

Optional grouping identifier to link multiple traces from the same conversationor process. For instance, you might use a chat thread ID.

None
metadatadict[str,Any] | None

Optional dictionary of additional metadata to attach to the trace.

None
disabledbool

If True, we will return a Trace but the Trace will not be recorded. This willnot be checked if there's an existing trace andeven_if_trace_running is True.

False

Returns:

TypeDescription
Trace

The newly created trace object.

Source code insrc/agents/tracing/create.py
deftrace(workflow_name:str,trace_id:str|None=None,group_id:str|None=None,metadata:dict[str,Any]|None=None,disabled:bool=False,)->Trace:"""    Create a new trace. The trace will not be started automatically; you should either use    it as a context manager (`with trace(...):`) or call `trace.start()` + `trace.finish()`    manually.    In addition to the workflow name and optional grouping identifier, you can provide    an arbitrary metadata dictionary to attach additional user-defined information to    the trace.    Args:        workflow_name: The name of the logical app or workflow. For example, you might provide            "code_bot" for a coding agent, or "customer_support_agent" for a customer support agent.        trace_id: The ID of the trace. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_trace_id()` to generate a trace ID, to guarantee that IDs are            correctly formatted.        group_id: Optional grouping identifier to link multiple traces from the same conversation            or process. For instance, you might use a chat thread ID.        metadata: Optional dictionary of additional metadata to attach to the trace.        disabled: If True, we will return a Trace but the Trace will not be recorded. This will            not be checked if there's an existing trace and `even_if_trace_running` is True.    Returns:        The newly created trace object.    """current_trace=get_trace_provider().get_current_trace()ifcurrent_trace:logger.warning("Trace already exists. Creating a new trace, but this is probably a mistake.")returnget_trace_provider().create_trace(name=workflow_name,trace_id=trace_id,group_id=group_id,metadata=metadata,disabled=disabled,)

get_current_trace

get_current_trace()->Trace|None

Returns the currently active trace, if present.

Source code insrc/agents/tracing/create.py
defget_current_trace()->Trace|None:"""Returns the currently active trace, if present."""returnget_trace_provider().get_current_trace()

get_current_span

get_current_span()->Span[Any]|None

Returns the currently active span, if present.

Source code insrc/agents/tracing/create.py
defget_current_span()->Span[Any]|None:"""Returns the currently active span, if present."""returnget_trace_provider().get_current_span()

agent_span

agent_span(name:str,handoffs:list[str]|None=None,tools:list[str]|None=None,output_type:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[AgentSpanData]

Create a new agent span. The span will not be started automatically, you should either dowith agent_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
namestr

The name of the agent.

required
handoffslist[str] | None

Optional list of agent names to which this agent could hand off control.

None
toolslist[str] | None

Optional list of tool names available to this agent.

None
output_typestr | None

Optional name of the output type produced by the agent.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[AgentSpanData]

The newly created agent span.

Source code insrc/agents/tracing/create.py
defagent_span(name:str,handoffs:list[str]|None=None,tools:list[str]|None=None,output_type:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[AgentSpanData]:"""Create a new agent span. The span will not be started automatically, you should either do    `with agent_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        name: The name of the agent.        handoffs: Optional list of agent names to which this agent could hand off control.        tools: Optional list of tool names available to this agent.        output_type: Optional name of the output type produced by the agent.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created agent span.    """returnget_trace_provider().create_span(span_data=AgentSpanData(name=name,handoffs=handoffs,tools=tools,output_type=output_type),span_id=span_id,parent=parent,disabled=disabled,)

function_span

function_span(name:str,input:str|None=None,output:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[FunctionSpanData]

Create a new function span. The span will not be started automatically, you should either dowith function_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
namestr

The name of the function.

required
inputstr | None

The input to the function.

None
outputstr | None

The output of the function.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[FunctionSpanData]

The newly created function span.

Source code insrc/agents/tracing/create.py
deffunction_span(name:str,input:str|None=None,output:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[FunctionSpanData]:"""Create a new function span. The span will not be started automatically, you should either do    `with function_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        name: The name of the function.        input: The input to the function.        output: The output of the function.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created function span.    """returnget_trace_provider().create_span(span_data=FunctionSpanData(name=name,input=input,output=output),span_id=span_id,parent=parent,disabled=disabled,)

generation_span

generation_span(input:Sequence[Mapping[str,Any]]|None=None,output:Sequence[Mapping[str,Any]]|None=None,model:str|None=None,model_config:Mapping[str,Any]|None=None,usage:dict[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[GenerationSpanData]

Create a new generation span. The span will not be started automatically, you should eitherdowith generation_span() ... or callspan.start() +span.finish() manually.

This span captures the details of a model generation, including theinput message sequence, any generated outputs, the model name andconfiguration, and usage data. If you only need to capture a modelresponse identifier, useresponse_span() instead.

Parameters:

NameTypeDescriptionDefault
inputSequence[Mapping[str,Any]] | None

The sequence of input messages sent to the model.

None
outputSequence[Mapping[str,Any]] | None

The sequence of output messages received from the model.

None
modelstr | None

The model identifier used for the generation.

None
model_configMapping[str,Any] | None

The model configuration (hyperparameters) used.

None
usagedict[str,Any] | None

A dictionary of usage information (input tokens, output tokens, etc.).

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[GenerationSpanData]

The newly created generation span.

Source code insrc/agents/tracing/create.py
defgeneration_span(input:Sequence[Mapping[str,Any]]|None=None,output:Sequence[Mapping[str,Any]]|None=None,model:str|None=None,model_config:Mapping[str,Any]|None=None,usage:dict[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[GenerationSpanData]:"""Create a new generation span. The span will not be started automatically, you should either    do `with generation_span() ...` or call `span.start()` + `span.finish()` manually.    This span captures the details of a model generation, including the    input message sequence, any generated outputs, the model name and    configuration, and usage data. If you only need to capture a model    response identifier, use `response_span()` instead.    Args:        input: The sequence of input messages sent to the model.        output: The sequence of output messages received from the model.        model: The model identifier used for the generation.        model_config: The model configuration (hyperparameters) used.        usage: A dictionary of usage information (input tokens, output tokens, etc.).        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created generation span.    """returnget_trace_provider().create_span(span_data=GenerationSpanData(input=input,output=output,model=model,model_config=model_config,usage=usage,),span_id=span_id,parent=parent,disabled=disabled,)

response_span

response_span(response:Response|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[ResponseSpanData]

Create a new response span. The span will not be started automatically, you should either dowith response_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
responseResponse | None

The OpenAI Response object.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False
Source code insrc/agents/tracing/create.py
defresponse_span(response:Response|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[ResponseSpanData]:"""Create a new response span. The span will not be started automatically, you should either do    `with response_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        response: The OpenAI Response object.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    """returnget_trace_provider().create_span(span_data=ResponseSpanData(response=response),span_id=span_id,parent=parent,disabled=disabled,)

handoff_span

handoff_span(from_agent:str|None=None,to_agent:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[HandoffSpanData]

Create a new handoff span. The span will not be started automatically, you should either dowith handoff_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
from_agentstr | None

The name of the agent that is handing off.

None
to_agentstr | None

The name of the agent that is receiving the handoff.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[HandoffSpanData]

The newly created handoff span.

Source code insrc/agents/tracing/create.py
defhandoff_span(from_agent:str|None=None,to_agent:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[HandoffSpanData]:"""Create a new handoff span. The span will not be started automatically, you should either do    `with handoff_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        from_agent: The name of the agent that is handing off.        to_agent: The name of the agent that is receiving the handoff.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created handoff span.    """returnget_trace_provider().create_span(span_data=HandoffSpanData(from_agent=from_agent,to_agent=to_agent),span_id=span_id,parent=parent,disabled=disabled,)

custom_span

custom_span(name:str,data:dict[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[CustomSpanData]

Create a new custom span, to which you can add your own metadata. The span will not bestarted automatically, you should either dowith custom_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
namestr

The name of the custom span.

required
datadict[str,Any] | None

Arbitrary structured data to associate with the span.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[CustomSpanData]

The newly created custom span.

Source code insrc/agents/tracing/create.py
defcustom_span(name:str,data:dict[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[CustomSpanData]:"""Create a new custom span, to which you can add your own metadata. The span will not be    started automatically, you should either do `with custom_span() ...` or call    `span.start()` + `span.finish()` manually.    Args:        name: The name of the custom span.        data: Arbitrary structured data to associate with the span.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created custom span.    """returnget_trace_provider().create_span(span_data=CustomSpanData(name=name,data=dataor{}),span_id=span_id,parent=parent,disabled=disabled,)

guardrail_span

guardrail_span(name:str,triggered:bool=False,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[GuardrailSpanData]

Create a new guardrail span. The span will not be started automatically, you should eitherdowith guardrail_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
namestr

The name of the guardrail.

required
triggeredbool

Whether the guardrail was triggered.

False
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False
Source code insrc/agents/tracing/create.py
defguardrail_span(name:str,triggered:bool=False,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[GuardrailSpanData]:"""Create a new guardrail span. The span will not be started automatically, you should either    do `with guardrail_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        name: The name of the guardrail.        triggered: Whether the guardrail was triggered.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    """returnget_trace_provider().create_span(span_data=GuardrailSpanData(name=name,triggered=triggered),span_id=span_id,parent=parent,disabled=disabled,)

transcription_span

transcription_span(model:str|None=None,input:str|None=None,input_format:str|None="pcm",output:str|None=None,model_config:Mapping[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[TranscriptionSpanData]

Create a new transcription span. The span will not be started automatically, you shouldeither dowith transcription_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
modelstr | None

The name of the model used for the speech-to-text.

None
inputstr | None

The audio input of the speech-to-text transcription, as a base64 encoded string ofaudio bytes.

None
input_formatstr | None

The format of the audio input (defaults to "pcm").

'pcm'
outputstr | None

The output of the speech-to-text transcription.

None
model_configMapping[str,Any] | None

The model configuration (hyperparameters) used.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False

Returns:

TypeDescription
Span[TranscriptionSpanData]

The newly created speech-to-text span.

Source code insrc/agents/tracing/create.py
deftranscription_span(model:str|None=None,input:str|None=None,input_format:str|None="pcm",output:str|None=None,model_config:Mapping[str,Any]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[TranscriptionSpanData]:"""Create a new transcription span. The span will not be started automatically, you should    either do `with transcription_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        model: The name of the model used for the speech-to-text.        input: The audio input of the speech-to-text transcription, as a base64 encoded string of            audio bytes.        input_format: The format of the audio input (defaults to "pcm").        output: The output of the speech-to-text transcription.        model_config: The model configuration (hyperparameters) used.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    Returns:        The newly created speech-to-text span.    """returnget_trace_provider().create_span(span_data=TranscriptionSpanData(input=input,input_format=input_format,output=output,model=model,model_config=model_config,),span_id=span_id,parent=parent,disabled=disabled,)

speech_span

speech_span(model:str|None=None,input:str|None=None,output:str|None=None,output_format:str|None="pcm",model_config:Mapping[str,Any]|None=None,first_content_at:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[SpeechSpanData]

Create a new speech span. The span will not be started automatically, you should either dowith speech_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
modelstr | None

The name of the model used for the text-to-speech.

None
inputstr | None

The text input of the text-to-speech.

None
outputstr | None

The audio output of the text-to-speech as base64 encoded string of PCM audio bytes.

None
output_formatstr | None

The format of the audio output (defaults to "pcm").

'pcm'
model_configMapping[str,Any] | None

The model configuration (hyperparameters) used.

None
first_content_atstr | None

The time of the first byte of the audio output.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False
Source code insrc/agents/tracing/create.py
defspeech_span(model:str|None=None,input:str|None=None,output:str|None=None,output_format:str|None="pcm",model_config:Mapping[str,Any]|None=None,first_content_at:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[SpeechSpanData]:"""Create a new speech span. The span will not be started automatically, you should either do    `with speech_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        model: The name of the model used for the text-to-speech.        input: The text input of the text-to-speech.        output: The audio output of the text-to-speech as base64 encoded string of PCM audio bytes.        output_format: The format of the audio output (defaults to "pcm").        model_config: The model configuration (hyperparameters) used.        first_content_at: The time of the first byte of the audio output.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    """returnget_trace_provider().create_span(span_data=SpeechSpanData(model=model,input=input,output=output,output_format=output_format,model_config=model_config,first_content_at=first_content_at,),span_id=span_id,parent=parent,disabled=disabled,)

speech_group_span

speech_group_span(input:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[SpeechGroupSpanData]

Create a new speech group span. The span will not be started automatically, you shouldeither dowith speech_group_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
inputstr | None

The input text used for the speech request.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False
Source code insrc/agents/tracing/create.py
defspeech_group_span(input:str|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[SpeechGroupSpanData]:"""Create a new speech group span. The span will not be started automatically, you should    either do `with speech_group_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        input: The input text used for the speech request.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    """returnget_trace_provider().create_span(span_data=SpeechGroupSpanData(input=input),span_id=span_id,parent=parent,disabled=disabled,)

mcp_tools_span

mcp_tools_span(server:str|None=None,result:list[str]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[MCPListToolsSpanData]

Create a new MCP list tools span. The span will not be started automatically, you shouldeither dowith mcp_tools_span() ... or callspan.start() +span.finish() manually.

Parameters:

NameTypeDescriptionDefault
serverstr | None

The name of the MCP server.

None
resultlist[str] | None

The result of the MCP list tools call.

None
span_idstr | None

The ID of the span. Optional. If not provided, we will generate an ID. Werecommend usingutil.gen_span_id() to generate a span ID, to guarantee that IDs arecorrectly formatted.

None
parentTrace |Span[Any] | None

The parent span or trace. If not provided, we will automatically use the currenttrace/span as the parent.

None
disabledbool

If True, we will return a Span but the Span will not be recorded.

False
Source code insrc/agents/tracing/create.py
defmcp_tools_span(server:str|None=None,result:list[str]|None=None,span_id:str|None=None,parent:Trace|Span[Any]|None=None,disabled:bool=False,)->Span[MCPListToolsSpanData]:"""Create a new MCP list tools span. The span will not be started automatically, you should    either do `with mcp_tools_span() ...` or call `span.start()` + `span.finish()` manually.    Args:        server: The name of the MCP server.        result: The result of the MCP list tools call.        span_id: The ID of the span. Optional. If not provided, we will generate an ID. We            recommend using `util.gen_span_id()` to generate a span ID, to guarantee that IDs are            correctly formatted.        parent: The parent span or trace. If not provided, we will automatically use the current            trace/span as the parent.        disabled: If True, we will return a Span but the Span will not be recorded.    """returnget_trace_provider().create_span(span_data=MCPListToolsSpanData(server=server,result=result),span_id=span_id,parent=parent,disabled=disabled,)

[8]ページ先頭

©2009-2025 Movatter.jp