Skip to main content

Python notifier for Errorgap error tracking.

Project description

errorgap

Python notifier for Errorgap. Captures exceptions, normalizes tracebacks with bounded source excerpts for readable frames, and ships notices to an Errorgap server. Single package covers plain Python, Django, Flask, and FastAPI.

Install

pip install errorgap

For framework integrations:

pip install "errorgap[django]"   # or [flask], [fastapi]

Requires Python 3.9+.

Configure

import errorgap

errorgap.init(
    endpoint=...,
    project_slug=...,
    api_key=...,
    environment="production",
)

init reads the same values from ERRORGAP_ENDPOINT, ERRORGAP_PROJECT_SLUG, ERRORGAP_PROJECT_ID, and ERRORGAP_API_KEY if you don't pass them. By default it installs a sys.excepthook to catch uncaught exceptions in scripts; pass capture_globals=False to skip.

Manual notification

try:
    risky()
except Exception as exc:
    errorgap.notify(exc, context={"component": "billing"})
    raise

notify returns a DeliveryResult (status, body, error, queued). The SDK never raises.

Django

Add to MIDDLEWARE:

MIDDLEWARE = [
    "errorgap.django.ErrorgapMiddleware",
    # ... your existing middleware ...
]

Flask

from flask import Flask
from errorgap.flask import init_app

app = Flask(__name__)
init_app(app)

FastAPI

from fastapi import FastAPI
from errorgap.fastapi import ErrorgapMiddleware

app = FastAPI()
app.add_middleware(ErrorgapMiddleware)

Configuration reference

Argument Default Notes
endpoint ERRORGAP_ENDPOINT or http://127.0.0.1:3030 Base URL, no trailing slash
project_slug ERRORGAP_PROJECT_SLUG Required
project_id ERRORGAP_PROJECT_ID Optional, embedded in payload
api_key ERRORGAP_API_KEY Sent as x-errorgap-project-key
environment ERRORGAP_ENVIRONMENT, ENV, or development
root_directory os.getcwd() Marks application frames; readable dependency frames also include bounded source excerpts
async_ True Background-thread delivery
logger logging.getLogger("errorgap") Pass None to silence
filter_keys ("password", "token", ...) Substring match, case-insensitive
capture_globals True Install sys.excepthook

Graceful shutdown

errorgap.flush(timeout=5)     # wait for queued deliveries
errorgap.shutdown(timeout=5)  # flush + tear down background thread

Verify

curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}],"context":{"environment":"development"}}'

Then trigger a real error and confirm it appears in the Errorgap UI.

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT.

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

errorgap-0.1.1.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.

errorgap-0.1.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file errorgap-0.1.1.tar.gz.

File metadata

  • Download URL: errorgap-0.1.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for errorgap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d8cee24b4a6e2febdd956ea9864142cd69643fc6e1fce91a7671f6527d7bc4a1
MD5 0d1d52d9a4918b9729f258477a5d9ba9
BLAKE2b-256 cf48543f61d7ea8f3347c821dcce857550883bfce3cfbefb12b09c0627f52630

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorgap-0.1.1.tar.gz:

Publisher: release.yml on errorgaphq/errorgap-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file errorgap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: errorgap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for errorgap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 670f344515484ecac33a1d20c09949ab49b0f49ddd0a6e9c7fb76121ac98815e
MD5 5471bca4310ec58e14453b1b1ced736a
BLAKE2b-256 b7d994c94c11d13794331fe6eb210e059592cf93d1a5e3a46f0efbc6bb573a07

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorgap-0.1.1-py3-none-any.whl:

Publisher: release.yml on errorgaphq/errorgap-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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