Metadata-Version: 2.4
Name: toolscope-obs
Version: 0.1.0
Summary: Production observability for your applications
License: MIT
Project-URL: homepage, https://toolscope.dev
Project-URL: source, https://github.com/toolscope/toolscope-python
Keywords: observability,monitoring,logging,sdk
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: requests
Requires-Dist: requests>=2.25.0; extra == "requests"
Provides-Extra: all
Requires-Dist: requests>=2.25.0; extra == "all"

# Toolscope Python SDK

Production observability and telemetry collection SDK for python applications and Wikimedia Toolforge tools.

## Installation

You can install the Toolscope SDK from PyPI:

```bash
pip install toolscope-obs
```

Or install with optional requests instrumentation support:

```bash
pip install "toolscope-obs[requests]"
```

## Quick Start

Initialize the SDK at the entry point of your application:

```python
import toolscope
import logging

# Initialize the SDK
toolscope.init(
    api_key="ts_live_your_api_key",
    backend_url="http://localhost:3000/api" # Optional: defaults to production api
)

# Start logging
logging.info("Application started")
```

## Job and Metric Monitoring

Isolate specific runs, jobs, or requests in your application using the `job` context manager:

```python
with toolscope.job("generate_image") as run_id:
    # All print outputs, logs, requests, and unhandled errors 
    # inside this block are automatically tagged with the job's run_id.
    print("Beginning image rendering task...")
    
    # Track custom metrics
    toolscope.metric("GPU_temp_c", 65.5)
```
