> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# trace

> Decorator for automatic function tracing with input/output capture.

Uses the global FiddlerClient when `client=` is not passed.
Supports both sync and async functions.

## Parameters

**func** `Callable | None` (default: None)

Function to decorate.

**name** `str | None` (default: None)

Custom span name (defaults to the function name).

**as\_type** `Literal['span', 'generation', 'chain', 'tool']` (default: 'span')

Span type — `"span"`, `"generation"`, `"chain"`, or `"tool"`.

**capture\_input** `bool` (default: True)

Capture function arguments as span input.

**capture\_output** `bool` (default: True)

Capture the return value as span output.

**client** `FiddlerClient | None` (default: get\_client())

FiddlerClient instance (defaults to `get_client()`).

**model** `str | None` (default: None)

LLM model name; sets `gen_ai.request.model`.

**user\_id** `str | None` (default: None)

User identifier; sets `user.id`.

**version** `str | None` (default: None)

Version string; sets `service.version`.

**system** `str | None` (default: None)

LLM provider; sets `gen_ai.system`.

## Returns

The decorated function.
