Official Watchup SDK for Python — error tracking, request tracing, and custom analytics
Project description
watchup
Official Python SDK for Watchup — error tracking, request tracing, and custom analytics for Python web applications.
Works with Flask, Django, FastAPI, and any WSGI framework. Zero required dependencies — uses the Python standard library only.
Installation
pip install watchup
Requires Python 3.9+.
Quick start
from watchup import Watchup
watchup = Watchup(
api_key="wup_live_xxxxxxxxxxxx", # Dashboard → Project Settings → API Keys
environment="production",
release="v1.2.3", # optional: git SHA or version tag
)
Flask
from flask import Flask
from watchup import Watchup
watchup = Watchup(api_key="wup_live_xxxxxxxxxxxx")
app = Flask(__name__)
watchup.init_app(app) # registers before_request, after_request, errorhandler hooks
init_app wires up:
- Request tracing — every request is recorded with method, route, status code, and duration
- Error capture — unhandled exceptions are reported with stack trace and request context
- Transparent re-raise — errors still propagate to your own error handlers
Django
Add WatchupDjangoMiddleware to your MIDDLEWARE list and set WATCHUP_API_KEY in settings.py:
# settings.py
MIDDLEWARE = [
"watchup.WatchupDjangoMiddleware",
# ... rest of your middleware
]
WATCHUP_API_KEY = "wup_live_xxxxxxxxxxxx"
WATCHUP_ENVIRONMENT = "production" # optional
WATCHUP_RELEASE = "v1.2.3" # optional
The middleware initialises the client once on first request and reuses it for the lifetime of the process.
FastAPI / Starlette
Use the WSGI wrapper or instrument manually with before / after logic via Starlette middleware:
from fastapi import FastAPI, Request
from watchup import Watchup
import time
watchup = Watchup(api_key="wup_live_xxxxxxxxxxxx")
app = FastAPI()
@app.middleware("http")
async def watchup_middleware(request: Request, call_next):
start = time.time()
response = await call_next(request)
ms = (time.time() - start) * 1000
# record trace manually
end = watchup.start_trace(f"{request.method} {request.url.path}")
end()
return response
WSGI middleware (framework-agnostic)
from watchup import Watchup, WatchupWSGI
watchup = Watchup(api_key="wup_live_xxxxxxxxxxxx")
# Flask example
from flask import Flask
flask_app = Flask(__name__)
flask_app.wsgi_app = WatchupWSGI(flask_app.wsgi_app, watchup)
# Any WSGI app
application = WatchupWSGI(application, watchup)
Manual tracking
Capture an error
try:
process_order(order_id)
except Exception as exc:
watchup.capture_error(exc, route="job.process_order", order_id=order_id)
Track a custom event
watchup.track("user.signed_up", {"plan": "pro", "source": "invite"})
watchup.track("order.placed", {"amount": 4999, "currency": "NGN"})
Time an operation
end = watchup.start_trace("db.query_users")
try:
rows = db.query("SELECT * FROM users")
end() # status defaults to "ok"
except Exception as exc:
end(status="err", meta={"query": "SELECT * FROM users"})
raise
User identification
Attach user identity to errors and traces:
# After authentication — in a middleware or login view
watchup.set_user("usr_42", email="alice@example.com", name="Alice", plan="pro")
# On logout
watchup.clear_user()
Once set, every capture_error, start_trace, and request trace will include the user context.
Configuration reference
| Parameter | Default | Description |
|---|---|---|
api_key |
(required) | Project API key (wup_live_…) |
base_url |
https://api.watchup.site |
Override for self-hosted deployments |
environment |
WATCHUP_ENV env var, or "production" |
Runtime label on every payload |
release |
None |
App version / git SHA |
flush_interval |
5.0 |
Seconds between automatic flushes |
max_batch_size |
100 |
Item count that triggers an immediate flush |
sample_rate |
1.0 |
Fraction of requests to trace (0–1) |
debug |
False |
Log SDK warnings to stderr |
Lifecycle
# Force an immediate flush
watchup.flush()
# Stop the background timer and flush remaining items (graceful shutdown)
watchup.shutdown()
The batcher runs on a daemon thread and registers an atexit handler, so queued items are flushed automatically when the process exits normally.
Links
- Website: watchup.site
- Documentation: watchup.site/docs
- Python SDK docs: watchup.site/docs/sdks/python
- Getting started: watchup.site/docs/getting-started
- Pricing: watchup.site/pricing
- Dashboard: app.watchup.site
License
MIT © Watchup Ltd
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 watchup-0.2.0.tar.gz.
File metadata
- Download URL: watchup-0.2.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cd6b37e8a60610e97d2cda42d1610d5cafd4567223b4b858ea8e40eb2092d3c
|
|
| MD5 |
562cf09a06f69a9d109c67cf75eeba39
|
|
| BLAKE2b-256 |
4fe8327d0d199aae39c1b5a2fec88d2295cdf58722c1f33fa373b33fd55c49af
|
File details
Details for the file watchup-0.2.0-py3-none-any.whl.
File metadata
- Download URL: watchup-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43e79bdc75d61c3ab568a23f73be2636edbec7940c9d9b7ca091ddafd9e799d
|
|
| MD5 |
55cc8349a459369105f6c14bda198bcf
|
|
| BLAKE2b-256 |
a7407e2db251fc894e9cc2dda7923459d9577a00bc4faaf60dc57d4b97b44c72
|