Python SDK
Install the SDK, call init once, and every unhandled exception in Django, FastAPI or Celery becomes a grouped issue with its stack trace.
1Install
pip install watchdock-errors
You need a project key. Open Issues in Watchdock: before your first error arrives, it shows each project's key, starting with wdk_.
2Initialise once
Call init() as early in startup as your framework allows, then add the integration for your framework.
# settings.pyimport watchdock_errorswatchdock_errors.init(api_key="wdk_…", environment="production", release="1.4.0")INSTALLED_APPS += ["watchdock_errors.integrations.django"]
The Django app registers its middleware for you. If you'd rather list it yourself, add watchdock_errors.integrations.django.DjangoErrorMiddleware to MIDDLEWARE instead.
Celery's prefork workers don't inherit the SDK's delivery thread. Call init() in a worker_process_init handler so every forked worker sends its own events.
3Verify it's reporting
Trigger a real error, like a request to a path that raises, and open Issues. It shows up within a few seconds, tagged with the environment and release you passed to init().
What gets captured
- Unhandled exceptions from requests, grouped into one issue per root cause with the stack trace and request.
- Celery failures, retries and revoked tasks, every registered task with its beat schedule, and a heartbeat on each periodic run, so a task that stops running gets flagged. Successful runs aren't reported.
- Anything you capture yourself, with an optional level.
try:process_payment()except Exception:watchdock_errors.capture_exception()watchdock_errors.capture_message("Queue depth high", level="warning")
Exceptions default to level error and messages to info.
Linking errors to nginx requests
If nginx forwards its request ID to your app, the SDK attaches it to every event as trace_id, with no code changes. That's what lets you jump from a failed request in your nginx logs to the exception it caused.
proxy_set_header X-Request-Id $request_id;
You can also pass trace_id= to capture_exception or capture_message, which wins over the header.
Personal data
By default the SDK strips Authorization, Cookie, Set-Cookie and X-Api-Key headers, never sends request bodies, and redacts query values whose names look sensitive, like token, password or session. Use before_send to scrub anything else, or return None to drop the event.
def scrub(event):event["request"]["headers"].pop("X-Internal-Token", None)return eventwatchdock_errors.init(api_key="wdk_…", before_send=scrub)
send_pii=True turns the default scrubbing off. Only set it if you need that data and know where it's going.
Troubleshooting
Nothing shows up
Check that init() ran in the process that raised the error, not just somewhere in the codebase. A forked Celery or Gunicorn worker that never called init() is the usual cause.
Events have no trace_id
nginx has to forward the header with proxy_set_header, not just log $request_id.
Sensitive data appears in events
Look for send_pii=True somewhere in your config. Scrubbing is on by default, so this is almost always an explicit override.