WatchForge Python SDK
Project description
WatchForge Python SDK (watchforge-sdk)
Python SDK for WatchForge — errors, traces, structured logs, and releases. Aligned with @watchforge/browser (JavaScript) and the other WatchForge language SDKs.
Install
pip install watchforge-sdk
Quick start
from watchforge_sdk import register
import logging
register(
endpoint="https://PUBLIC_KEY@dev.watchforges.com/PROJECT_ID",
app_env="production",
release="my-api@1.0.0", # for Releases / crash-free
traces_sample_rate=1.0, # 100% of traces (Sentry-style 0.0–1.0)
enable_logs=True, # structured logs (default True)
)
logging.info("hello") # captured automatically when enable_logs + auto_capture_logging
Feature matrix
| Feature | Supported | Notes |
|---|---|---|
| Errors | Yes | Unhandled exceptions + capture_exception / capture_message |
| Traces | Yes | Integrations (e.g. Django) + start_transaction; sampled via traces_sample_rate |
| Session Replay | Not supported | Browser / mobile client SDKs only |
| Logs | Yes | enable_logs + stdlib logging (auto_capture_logging) + capture_log |
| Releases | Yes | Set release at register(); view under Releases (project-scoped) |
Errors
With default settings, unhandled exceptions are captured automatically. For handled errors:
from watchforge_sdk import capture_exception, capture_message
try:
process()
except Exception as e:
capture_exception(e)
capture_message("payment processed", level="info")
Traces
Set traces_sample_rate once at register (Sentry-style 0.0–1.0). Unsampled traces are dropped and not sent.
Prefer framework integrations (e.g. Django) so request traces are created automatically when the sample rate is > 0. Manual instrumentation:
from watchforge_sdk import start_transaction, finish_transaction
txn = start_transaction("/api/orders", "Create Order", op="http.server")
span = txn.start_span("db.query", "INSERT orders")
span.finish()
finish_transaction("ok")
Session Replay
Not supported in the Python SDK. Use @watchforge/browser (or other client SDKs) for session replay.
Logs
Like Sentry’s enableLogs: leave enable_logs=True (default). With auto_capture_logging=True, messages from Python’s logging module are sent automatically. You can also call capture_log directly. Set enable_logs=False to disable both auto capture and capture_log.
import logging
from watchforge_sdk import capture_log, capture_api_log, flush_logs
logging.info("user signed in") # auto-captured
capture_log("order created", level="info", attributes={"order_id": "123"})
capture_api_log("GET /orders", attributes={"status": 200})
flush_logs()
Releases
Set release once at register() (e.g. my-api@1.2.3). Errors and traces tagged with that version appear under Releases for the project (sidebar → Releases). Omit release if you do not need release tracking.
Config options
| Option | Type | Default | Description |
|---|---|---|---|
endpoint / dsn |
str | required | Project DSN |
app_env / environment |
str | "production" |
Environment name |
release |
str | None |
Deploy version for Releases / crash-free (e.g. my-api@1.2.3) |
auto_capture_exceptions |
bool | True |
Capture unhandled exceptions |
enable_logs |
bool | True |
Gate structured logs (Sentry-style). When False, capture_log is a no-op and auto logging is skipped |
auto_capture_logging |
bool | True |
Capture stdlib logging messages (requires enable_logs=True) |
logging_level |
int | logging.INFO |
Minimum level for auto log capture |
debug |
bool | False |
Verbose SDK logging |
integrations |
list | None |
e.g. [DjangoHandler()] for request traces |
traces_sample_rate |
float | 1.0 |
Fraction of traces to send (0.0–1.0). 1.0 = 100%, 0.1 = 10%, 0.0 = off. Values > 1 are treated as percent (100 → 1.0). |
Cron monitors
from watchforge_sdk import capture_checkin
check_in_id = capture_checkin("nightly-job", status="in_progress", monitor_config={...})
capture_checkin("nightly-job", status="ok", check_in_id=check_in_id)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file watchforge_sdk-0.1.1.tar.gz.
File metadata
- Download URL: watchforge_sdk-0.1.1.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fafc83aa5f75eabd4469f4fd9c9056ea8aea1df2298235ed0e605aedb3c2d8a
|
|
| MD5 |
9c5f833e16e15551b95287bcf4647a23
|
|
| BLAKE2b-256 |
23020ce8e1dbc5fdc220b40ec1dadc28a7157c73b73ccaf44a82085aaa7da750
|
File details
Details for the file watchforge_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: watchforge_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc7e70d9f0646f826235ef4ac47cf440ddc3099d4348145f7f06d61e42b91ba2
|
|
| MD5 |
999de67780adbb38ef2da62241cbb52b
|
|
| BLAKE2b-256 |
66fdef4a9e53a4d1af13378fbe9c89abb8f81a4f01fb2620dab926a03221fb56
|