# Set up tracing

{% hint style="info" %}
**You are looking at the old Evidently documentation**: this API is available with versions 0.6.7 or lower. Check the newer version [here](https://docs.evidentlyai.com/introduction).
{% endhint %}

For an end-to-end example, check the [Tracing Quickstart](/get-started/quickstart-cloud/cloud_quickstart_tracing.md).

## Installation and Imports

Install the `tracely` package from PyPi.

```python
!pip install tracely 
```

Imports:

```python
from tracely import init_tracing
from tracely import trace_event
```

## Initialize tracing

Use `init_tracing` to enable tracely tracing. Example:

```python
init_tracing(
   address="https://app.evidently.cloud/",
   api_key=”YOUR_EVIDENTLY_TOKEN”,
   project_id="YOUR_PROJECT_ID",
   export_name="YOUR_TRACING_DATASET_NAME",
   )
```

### Tracing parameters

| **Parameter**                  | **Description**                                                                                                                                                                                                                        |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `address: Optional[str]`       | <p>The URL of the collector service where tracing data will be sent. For Evidently Cloud, set <code><https://app.evidently.cloud/></code>.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p>           |
| `exporter_type: Optional[str]` | <p>Specifies the type of exporter to use for tracing. Options are <code>grpc</code> for gRPC protocol or <code>http</code> for HTTP protocol.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p>        |
| `api_key: Optional[str]`       | <p>The authorization API key for Evidently Cloud tracing. This key authenticates your requests and is necessary for sending data to Evidently Cloud.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p> |
| `project_id: str`              | <p>The ID of your Project in Evidently Cloud.<br><strong>Required:</strong> Yes, <strong>Default:</strong> <code>None</code></p>                                                                                                       |
| `export_name: Optional[str]`   | <p>A string name assigned to the exported tracing data. All data with the same <code>export\_name</code> will be grouped into a single dataset.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p>      |
| `as_global: bool = True`       | Indicates whether to register the tracing provider globally for OpenTelemetry (`opentelemetry.trace.TracerProvider`) or use it locally within a scope. **Default:** `True`                                                             |

## Tracing a function

To trace a function call use `trace_event()` decorator.

**Example 1.** To log all arguments of the function:

```
@trace_event()
```

**Example 2.** To log only input arguments of the function:

```
@trace_event(track_args=[])
```

**Example 3.** To log only "arg1" and "arg2":

```
@trace_event(track_args=["arg1", "arg2"])
```

See the [Tracing Quickstart](/get-started/quickstart-cloud/cloud_quickstart_tracing.md) for an end-to-end example.

| **Parameter**                      | **Description**                                                                                                                                                                                                                                                                                               |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `span_name: Optional[str]`         | <p>The name of the span to track. This is how the event will be labeled in the trace. By giving it a name, you can identify and analyze this particular step within your tracing data.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p>                                      |
| `track_args: Optional[List[str]]`  | <p>A list of arguments to capture during tracing. If set to <code>None</code>, it captures all arguments by default. If set to <code>\[]</code>, it captures no arguments.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p>                                                  |
| `ignore_args: Optional[List[str]]` | <p>A list of arguments to ignore from tracking. For instance, if a function has sensitive information that you don’t want to log, you can list those arguments here. If set to <code>None</code>, no arguments are ignored.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>None</code></p> |
| `track_output: Optional[bool]`     | <p>Indicates whether to track the output of the function call. If set to <code>True</code>, the trace will include the function’s output, allowing you to see not just what was passed in but also what was returned.<br><strong>Required:</strong> No, <strong>Default:</strong> <code>True</code></p>       |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-old.evidentlyai.com/user-guide/tracing/set_up_tracing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
