# traceable

> **Function** in `langsmith`

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

Trace a function with langsmith.

## 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. |
| `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/ce9e9e8973442b33e98ec3ce1b9c2dd3f58a43a7/python/langsmith/run_helpers.py#L352)