# traceable

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/run_helpers/traceable)

Trace a function with langsmith.

!!! warning "Experimental"
    `address` is in beta. It is enabled per workspace; a
    workspace without it rejects the runs, so tracing is lost rather than
    falling back to a project. It may change without notice.

## Signature

```python
traceable(
    args: Any = (),
    kwargs: Any = {},
) -> Union[Callable, Callable[[Callable], Callable]]
```

## Description

!!! note

Requires that `LANGSMITH_TRACING_V2` be set to 'true' in the environment.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `run_type` | `unknown` | Yes | The type of run (span) to create.  Examples: `llm`, `chain`, `tool`, `prompt`, `retriever`, etc.  Defaults to "chain". |
| `name` | `unknown` | Yes | The name of the run. Defaults to the function name. |
| `metadata` | `unknown` | Yes | The metadata to add to the run. Defaults to `None`. |
| `tags` | `unknown` | Yes | The tags to add to the run. Defaults to `None`. |
| `client` | `unknown` | Yes | The client to use for logging the run to LangSmith. Defaults to `None`, which will use the default client. |
| `reduce_fn` | `unknown` | Yes | A function to reduce the output of the function if the function returns a generator.  Defaults to `None`, which means the values will be logged as a list.  !!! note      If the iterator is never exhausted (e.g. the function returns an     infinite generator), this will never be called, and the run itself will     be stuck in a pending state. |
| `project_name` | `unknown` | Yes | The name of the project to log the run to.  Defaults to `None`, which will use the default project. |
| `address` | `unknown` | Yes | (beta) An `AgentAddress`, such as `ls.AgentAddress(id, environment)`, to log the run to instead of a project. Cannot be combined with a project in the same call. Defaults to the `LANGSMITH_AGENT_*` env vars. |
| `process_inputs` | `unknown` | Yes | Custom serialization / processing function for inputs.  Defaults to `None`. |
| `process_outputs` | `unknown` | Yes | Custom serialization / processing function for outputs.  Defaults to `None`. |
| `dangerously_allow_filesystem` | `unknown` | Yes | Whether to allow filesystem access for attachments.  Defaults to `False`.  Traces that reference local filepaths will be uploaded to LangSmith. In general, network-hosted applications should not be using this because referenced files are usually on the user's machine, not the host machine. |
| `enabled` | `unknown` | Yes | Whether tracing is enabled for this function.  Defaults to `None`, which will use the default value from the current context. |
| `exceptions_to_handle` | `unknown` | Yes | Exception types to ignore when logging errors.  If an exception of one of these types is raised, the run will still be recorded but the error field will be `None` instead of containing the full traceback.  Defaults to `None`. |

## Returns

`Union[Callable, Callable[[Callable], Callable]]`

The decorated function.

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/52e79add98f6559235d1eb00f5f533b9be6d4cf6/python/langsmith/run_helpers.py#L416)