Skip to main content

Application error tracking SDK for the Watchdock platform

Project description

watchdock-errors

Python SDK for application-level error tracking on the Watchdock platform.

Installation

pip install watchdock-errors

With framework extras:

pip install "watchdock-errors[django]"
pip install "watchdock-errors[fastapi]"

Quickstart

import watchdock_errors

watchdock_errors.init(
    api_key="wdk_xxx",
    environment="production",
    release="1.0.0",
)

Django

# settings.py
MIDDLEWARE = [
    ...
    "watchdock_errors.integrations.django.DjangoErrorMiddleware",
]

Or via INSTALLED_APPS for automatic registration:

INSTALLED_APPS = [
    ...
    "watchdock_errors.integrations.django",
]

FastAPI

from watchdock_errors.integrations.fastapi import setup_watchdock

setup_watchdock(app)

Manual capture

# Capture the current exception
try:
    process_payment()
except Exception:
    watchdock_errors.capture_exception()

# Capture a specific exception
watchdock_errors.capture_exception(exc)

# Capture a message
watchdock_errors.capture_message("Stripe webhook signature invalid")

# Capture a message with a custom level
watchdock_errors.capture_message("Queue depth high", level="warning")

Event levels

Every event carries a level. Exceptions default to "error"; messages default to "info" unless you pass level explicitly to capture_message.

Correlating with nginx requests

If your app is behind nginx and you've added $request_id to your access log format (see the nginx log collection docs) and forwarded it to your app via proxy_set_header X-Request-Id $request_id;, this SDK automatically reads that header off every captured request and attaches it as trace_id — no code changes needed. This lets WatchDock link a failed request in your nginx access logs directly to the exception it produced.

You can also pass trace_id explicitly, which takes priority over the auto-extracted value:

watchdock_errors.capture_exception(exc, trace_id=my_trace_id)
watchdock_errors.capture_message("Queue depth high", level="warning", trace_id=my_trace_id)

SDK initialization

When init() is called, the SDK sends a one-time, fire-and-forget ping to the platform (with the SDK version and environment) to register that it started up. This never blocks application startup and any failure is silently ignored.

PII scrubbing

By default, Authorization, Cookie, and X-Api-Key headers are stripped and the request body is not sent. Set send_pii=True to disable scrubbing.

Use the before_send hook for custom scrubbing:

def scrub(event):
    event["request"]["headers"].pop("X-Internal-Token", None)
    return event  # return None to drop the event entirely

watchdock_errors.init(api_key="wdk_xxx", before_send=scrub)

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

watchdock_errors-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

watchdock_errors-0.3.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file watchdock_errors-0.3.0.tar.gz.

File metadata

  • Download URL: watchdock_errors-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for watchdock_errors-0.3.0.tar.gz
Algorithm Hash digest
SHA256 303b5b35841ab9e4ba4a6a63cc6f895c43592e4e6dbf5212bee98d3203690d85
MD5 8a0503d3d9bf33e56fae7b67f6bb3d89
BLAKE2b-256 de24588c4f672a97c10b0a712a635e6dcdd910027b7f59aa373392128b09f91a

See more details on using hashes here.

File details

Details for the file watchdock_errors-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for watchdock_errors-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bda1152dca08a6a0d24c2495a076761736c3293ec4d88ac07480c5448b14a8d
MD5 86b69c6d901f624dea28dbadcd8b9baf
BLAKE2b-256 0013827873f2c79d4abc46e4b3f0a73acb6dbf949cbc35d46cdebd68e84b1be3

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