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.2.tar.gz (33.5 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.2-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watchforge_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 33.5 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.2.tar.gz
Algorithm Hash digest
SHA256 352f71b05adafc2fa070e49c55f06fe031bab2af559e42caee1915ca555a271c
MD5 e8a4916b335bf42ff34c73bff50b8403
BLAKE2b-256 c17a542a021f661015eb36751a64bb215f98ac84104a0a0c6241f9a451bb8207

See more details on using hashes here.

File details

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

File metadata

  • Download URL: watchforge_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c7661e252415b514e6c8e71df5cd26af6829908c1346efddefcfc9d261a25f0a
MD5 fce015c2d4e7b41d17aae3541eab6341
BLAKE2b-256 160b1bcf0582feefa12640de5faf33af4fe313890e0ea08ffe51cca83b99cc53

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