agentscope.tracing

The tracing interface class in agentscope.

setup_tracing(endpoint)[source]

Set up the AgentScope tracing by configuring the endpoint URL.

Parameters:

endpoint (str) – The endpoint URL for the tracing exporter.

Return type:

None

trace(name)[source]

A generic tracing decorator for synchronous and asynchronous functions.

Parameters:

name (str) – The name of the span to be created.

Returns:

Returns a decorator that wraps the given function with OpenTelemetry tracing.

Return type:

Callable

trace_llm(func)[source]

Trace the LLM call with OpenTelemetry.

Parameters:

func (Callable) – The function to be traced, which should be a coroutine that returns either a ChatResponse or an AsyncGenerator of ChatResponse.

Returns:

A wrapper function that traces the LLM call and handles input/output and exceptions.

Return type:

Callable

trace_reply(func)[source]

Trace the agent reply call with OpenTelemetry.

Parameters:

func (Callable[…, Coroutine[Any, Any, Msg]]) – The agent async reply function to be traced.

Returns:

A wrapper function that traces the agent reply call and handles input/output and exceptions.

Return type:

Callable[…, Coroutine[Any, Any, Msg]]

trace_format(func)[source]

Trace the format function of the formatter with OpenTelemetry.

Parameters:

func (Callable[…, Coroutine[Any, Any, list[dict]]]) – The async format function to be traced.

Returns:

An async wrapper function that traces the format call and handles input/output and exceptions.

Return type:

Callable[…, Coroutine[Any, Any, list[dict]]]

trace_toolkit(func)[source]

Trace the toolkit call_tool_function method with OpenTelemetry.

Parameters:

func (Callable[[...], Coroutine[Any, Any, AsyncGenerator[ToolResponse, None]]])

Return type:

Callable[[…], Coroutine[Any, Any, AsyncGenerator[ToolResponse, None]]]

trace_embedding(func)[source]

Trace the embedding call with OpenTelemetry.

Parameters:

func (Callable[[...], Coroutine[Any, Any, EmbeddingResponse]])

Return type:

Callable[[…], Coroutine[Any, Any, EmbeddingResponse]]