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

# Initialization

> Set up and initialize the Scale GP Tracing SDK in your Python applications.

The SGP Tracing SDK provides a convenient way to instrument your Python applications with tracing capabilities, allowing you to generate, manage, and send spans to the Scale GP platform. This enables detailed monitoring and debugging of your workflows.

<Info>Python SDK tracing is currently only available in the Beta SDK.</Info>

## Installation

First, install the `scale-gp-beta` package using pip:

```sh theme={null}
pip install --pre scale-gp-beta
```

## Initialisation

Before you can create any traces or spans, you must initialize the tracing SDK. It's best practice to do this once at your application's entry point.

You have two primary options for initialization:

### Initialize with an `SGPClient`

This method gives you full control over the `SGPClient`'s configuration (e.g., `base_url`, `timeout`).

```Python theme={null}
import scale_gp_beta.lib.tracing as tracing
from scale_gp_beta import SGPClient

# Replace with your actual API Key and Account ID
client = SGPClient(api_key="YOUR_API_KEY", account_id="YOUR_ACCOUNT_ID")
tracing.init(client=client)
```

### Initialize using Environment Variables

If you have set the `SGP_API_KEY` and `SGP_ACCOUNT_ID` environment variables, you can omit passing a client. The SDK will automatically attempt to create a default `SGPClient` for you.

```bash theme={null}
export SGP_API_KEY="sk-your-api-key"
export SGP_ACCOUNT_ID="your-account-id"
```

Then, in your Python code:

```python theme={null}
import scale_gp_beta.lib.tracing as tracing

# The SDK will automatically find SGP_API_KEY and SGP_ACCOUNT_ID
# from your environment variables.
tracing.init()
```

## Disabling Tracing

You can control whether tracing data is collected and exported. This is useful for development, testing, or specific environments where tracing is not desired.

### Environment Variable

```bash theme={null}
export DISABLE_SCALE_TRACING=true
```

### Programmatically

Pass the `disabled=True` parameter directly to the `init()` function. This will override the environment variable setting.

```python theme={null}
import scale_gp_beta.lib.tracing as tracing
from scale_gp_beta import SGPClient

# Tracing will be disabled, regardless of environment variables
tracing.init(client=SGPClient(api_key="...", account_id="..."), disabled=True)
```
