Skip to main content

Python notifier for Errorgap error tracking.

Project description

errorgap

Python notifier for Errorgap. Captures exceptions, normalizes tracebacks, 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() Used to mark frames as in_app
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.0.tar.gz (12.1 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.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: errorgap-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 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.0.tar.gz
Algorithm Hash digest
SHA256 773330a72fc28c84bb69effb03929cfb9b4e148c1ef72ed5120adcf039f47b28
MD5 283a512b356baba2c8bec324b94a1e23
BLAKE2b-256 f6793264652d85fd3e3dfc98a429de69299b672433f9d138fec08f0eeeb77410

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorgap-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: errorgap-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f169bba1d4c56e028d1e29f3bdd042efa052f9b3f01a9c8c42f4d6d30277795
MD5 858ac1c3a85a80d19a7c040b8ad376bd
BLAKE2b-256 31e9663686d663ce6f27a893446f4499b289d259d53437ae5be42106277d1c66

See more details on using hashes here.

Provenance

The following attestation bundles were made for errorgap-0.1.0-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