Skip to main content

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 optional)
pip install "devlite[flask]"   # + Flask 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.

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):

from flask import request

@app.before_request
def identify():
    devlite.set_user({"id": request.remote_addr, "email": request.headers.get("X-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/secret are 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,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

devlite-0.1.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

devlite-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file devlite-0.1.0.tar.gz.

File metadata

  • Download URL: devlite-0.1.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for devlite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bccd6b49f90d38e7094eae78c93d6f5bb0f3231e17458e83ceba9583cecf119b
MD5 68f77919ab7848899f069285f8d75ea4
BLAKE2b-256 7fe845445283432230383fab16fca550bbd7e5c9ac920bc4ef2a8ab5ad732dae

See more details on using hashes here.

File details

Details for the file devlite-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: devlite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for devlite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9559814bf86ba11bee23b26138db1d2b2351127640b451d7cff24cf9a32d9efc
MD5 72f141a94fdbe418deac6fedf903a737
BLAKE2b-256 29de01d2b913e9278b6931867dc4aff0ac1de89d2655274dcb24e0c6bf7aefd2

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 Sentry Error logging StatusPage Status page