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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8cee24b4a6e2febdd956ea9864142cd69643fc6e1fce91a7671f6527d7bc4a1
|
|
| MD5 |
0d1d52d9a4918b9729f258477a5d9ba9
|
|
| BLAKE2b-256 |
cf48543f61d7ea8f3347c821dcce857550883bfce3cfbefb12b09c0627f52630
|
Provenance
The following attestation bundles were made for errorgap-0.1.1.tar.gz:
Publisher:
release.yml on errorgaphq/errorgap-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
errorgap-0.1.1.tar.gz -
Subject digest:
d8cee24b4a6e2febdd956ea9864142cd69643fc6e1fce91a7671f6527d7bc4a1 - Sigstore transparency entry: 2194964374
- Sigstore integration time:
-
Permalink:
errorgaphq/errorgap-python@c958fec585768bfd7af3e63e0db1bcd1f519c9e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/errorgaphq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c958fec585768bfd7af3e63e0db1bcd1f519c9e2 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
670f344515484ecac33a1d20c09949ab49b0f49ddd0a6e9c7fb76121ac98815e
|
|
| MD5 |
5471bca4310ec58e14453b1b1ced736a
|
|
| BLAKE2b-256 |
b7d994c94c11d13794331fe6eb210e059592cf93d1a5e3a46f0efbc6bb573a07
|
Provenance
The following attestation bundles were made for errorgap-0.1.1-py3-none-any.whl:
Publisher:
release.yml on errorgaphq/errorgap-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
errorgap-0.1.1-py3-none-any.whl -
Subject digest:
670f344515484ecac33a1d20c09949ab49b0f49ddd0a6e9c7fb76121ac98815e - Sigstore transparency entry: 2194964379
- Sigstore integration time:
-
Permalink:
errorgaphq/errorgap-python@c958fec585768bfd7af3e63e0db1bcd1f519c9e2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/errorgaphq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c958fec585768bfd7af3e63e0db1bcd1f519c9e2 -
Trigger Event:
push
-
Statement type: