devlite — Python SDK
AI-powered observability for Python. Add two lines, get automatic request tracking, error capture, error grouping, source context, user tracking, and slow-endpoint detection — no config files, no manual instrumentation, zero runtime dependencies.
This is the Python counterpart of @devlite/nodejs — both SDKs speak the same batch protocol to the DevLite ingest API.
Install
pip install devlite # core (Flask/FastAPI/Django optional)
pip install "devlite[flask]" # + Flask instrumentation
pip install "devlite[fastapi]" # + FastAPI instrumentation
pip install "devlite[django]" # + Django instrumentation
60-second quickstart (Flask)
from flask import Flask
import devlite
devlite.init(api_key="dl_live_xxxxx")
app = Flask(__name__)
devlite.instrument_flask(app)
That's it — every HTTP request, slow endpoint, and unhandled exception is now captured automatically, with:
- Grouped errors — the same bug occurring 1,000 times shows up as one issue, not 1,000
- Real source code context — the actual lines around the crash, read live from disk
- Automatic sensitive-data scrubbing — emails, tokens, passwords redacted before anything leaves your process
- User impact tracking — know exactly which users hit which bugs
Point api_key/endpoint at your own DevLite ingest instance (Supabase-backed) to start seeing data.
Auto-instrumentation for every framework
One call per framework, with the same automatic request/slow-request/error/user tracking:
FastAPI (any Starlette app) — call right after creating the app:
from fastapi import FastAPI
import devlite
devlite.init(api_key="dl_live_xxxxx")
app = FastAPI()
devlite.instrument_fastapi(app) # before the server starts
Django — instrument_django() inserts devlite._django.InstrumentDjangoMiddleware at the top of your MIDDLEWARE setting:
import devlite
devlite.init(api_key="dl_live_xxxxx")
devlite.instrument_django()
Or add the middleware manually (must be near the top, index 0 ideally):
MIDDLEWARE = [
"devlite._django.InstrumentDjangoMiddleware",
...
]
Any other framework (or plain WSGI/ASGI) still works through the manual API below.
Manual capture API
# Capture a handled error with extra context
devlite.capture_error(err, {"userId": "123", "action": "checkout"})
devlite.capture_error(err, {"fingerprint": "payment-timeout"}) # force grouping key
# Non-error event
devlite.capture_message("Payment retried after timeout", "warning")
# Custom metric — feeds forecasting/anomaly detection
devlite.report_metric("order.total", 42.5, unit="USD", tags={"region": "lagos"})
# Structured log line
devlite.capture_log("checkout completed", "info", {"orderId": "ord_123", "durationMs": 250})
# Trace a unit of work
span = devlite.start_span("checkout.process", {"trace_id": "abc"})
span.end("ok") # "ok" | "error"
# Tell DevLite about a deployment (powers before/after performance views)
devlite.report_deployment(version="v2.1.3", commit_sha="a1b2c3d")
# Breadcrumbs attach to the next captured error, improving AI root-cause
devlite.add_breadcrumb({"type": "business_event", "note": "user started checkout"})
# Tag all subsequent events
devlite.set_tag("region", "lagos")
User impact tracking
set_user() is scoped to the current request (via contextvars, so concurrent requests never leak each other's identity):
# Flask
from flask import request
@app.before_request
def identify():
devlite.set_user({"id": request.remote_addr, "email": request.headers.get("X-User-Email")})
# FastAPI — inside any endpoint
devlite.set_user({"id": "u-123", "email": "a@example.com"})
# Django — inside any view
def my_view(request):
devlite.set_user({"id": request.user.id, "email": request.user.email})
Configuration options
devlite.init({
"api_key": "dl_live_xxxxx", # required
"environment": "production", # default: $DEVLITE_ENVIRONMENT or "development"
"service_name": "payments-api", # default: $DEVLITE_SERVICE_NAME or current folder
"release": "v2.1.3", # e.g. git sha, shown in deployment views
"sample_rate": 1.0, # 0.0–1.0. Sampling is COHERENT: a sampled-out
# request drops its errors/spans/logs/metrics together.
"capture_body": False, # capture (redacted) request headers — off by default
"flush_interval_ms": 5000, # how often batched events are sent
"gzip": True, # compress request bodies (Content-Encoding: gzip)
"debug": False, # log SDK internals
"on_error": lambda err: print(err), # SDK-internal send failures
})
All of api_key, service_name, release, and endpoint can also be set via environment variables (DEVLITE_API_KEY, DEVLITE_SERVICE_NAME, DEVLITE_RELEASE, DEVLITE_ENDPOINT).
Serverless / short-lived processes
Events are batched, so call flush() before your function returns:
devlite.flush()
Graceful shutdown
The SDK flushes remaining events on interpreter exit (atexit). If you manage shutdown yourself:
devlite.close()
What makes this competitive
- Automatic error grouping — the same underlying bug, however many times it fires, is fingerprinted and grouped into one issue, instead of flooding your dashboard with duplicates.
- Source code context — every captured error includes the actual lines of code around the crash, read live from disk, not just a bare stack trace.
- Automatic sensitive-data scrubbing — on by default. Emails, JWTs, bearer tokens, AWS keys, credit card numbers, and any field literally named
password/token/secretare redacted before anything leaves your process. - Never blocks your app — all sends are async (background thread), batched, and retried with backoff. If DevLite's backend is unreachable, your app keeps running.
- Zero dependencies — pure Python standard library.
Development
pip install -e ".[flask,fastapi,django,test]"
python -m pytest
License
MIT
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 devlite-0.1.1.tar.gz.
File metadata
- Download URL: devlite-0.1.1.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2bc0c0bdf56695c5f1f7a1108927fe9694968c02745d456ab02e70f4685154
|
|
| MD5 |
83e92d1ac9840389ff61a4c8a81fe689
|
|
| BLAKE2b-256 |
3cce76758addb6985f1f5438be345c982b7e7a4aaec0358ea227f6800bdf6f82
|
File details
Details for the file devlite-0.1.1-py3-none-any.whl.
File metadata
- Download URL: devlite-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0799a4d0922f3139b36eb36070e1548b924ffa630540bc04e7893210f4721a3f
|
|
| MD5 |
d5f452217415f49dbe74bb3328503c55
|
|
| BLAKE2b-256 |
4ae4fae9d0d398704a6c6286cce346d4704879a6a84ed4c71cfef89b54049048
|