Skip to main content

WatchForge Python SDK

Project description

WatchForge Python SDK (watchforge-sdk)

Python SDK for WatchForge — errors, traces, structured logs, releases, and cron monitors.

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 (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 SDKs only
Logs Yes enable_logs + stdlib logging + capture_log
Releases Yes Set release at register(); view under Releases
Cron monitors Yes capture_checkin (in_progressok / error)

Errors

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 (0.0–1.0). Prefer Django integration for automatic request traces.

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 for session replay.

Logs

Leave enable_logs=True (default). With auto_capture_logging=True, stdlib logging is forwarded. Set enable_logs=False to disable.

from watchforge_sdk import capture_log, flush_logs

capture_log("order created", level="info", attributes={"order_id": "123"})
flush_logs()

Releases

Set release once at register() (e.g. my-api@1.2.3). Versions appear under Releases for the project.

Cron monitors

Report scheduled job health with check-ins (in_progressok / error):

from watchforge_sdk import capture_checkin

monitor_config = {
    "schedule": {"type": "crontab", "value": "0 * * * *"},
    "timezone": "UTC",
    "check_margin": 5,
    "max_runtime": 30,
}

check_in_id = capture_checkin(
    "nightly-job",
    status="in_progress",
    monitor_config=monitor_config,
)
# ... run job ...
capture_checkin("nightly-job", status="ok", check_in_id=check_in_id)

Config options

Option Type Default Description
endpoint / dsn str required Project DSN
app_env str "production" Environment name
release str None Deploy version for Releases
enable_logs bool True Gate structured logs
auto_capture_logging bool True Capture stdlib logging
traces_sample_rate float 1.0 Trace sample rate 0.0–1.0
integrations list None e.g. [DjangoHandler()]

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watchforge_sdk-0.1.5.tar.gz (36.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

watchforge_sdk-0.1.5-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file watchforge_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: watchforge_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for watchforge_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bf13a76fcb5e8a3fefa7acce4c56d66559f7d6b67555787650aaaa39817241c9
MD5 6c67288e947fccda1ce3559a87e26ddf
BLAKE2b-256 5f6a5a08ec3c7118421c1958877fe4feb9127c8a16c9cd2fb329e0ad605d7ebc

See more details on using hashes here.

File details

Details for the file watchforge_sdk-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: watchforge_sdk-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for watchforge_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 57fb1611ef6a1c1d61d3893aa88ef3d3025bcc279cadd6c60b3ac459291256de
MD5 24317a0229adb4695455322e3b583216
BLAKE2b-256 c674dcecdbc5e20faca693a0a2979f59be431879aafc89d31a27d68cea808293

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page