Current collected state Current
Observed since 20 Oct, 21:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Afen Python SDK - capture and send runtime errors to Afen
Capture runtime errors and send them to an Afen instance.
sys.excepthookpip install afen-client
from afen.client import AfenClient
client = AfenClient(
api_url="http://localhost:3000",
api_key="your-api-token",
service_name="my-service",
)
That's it. A global sys.excepthook is registered automatically — all unhandled exceptions are forwarded to Afen without any further setup.
try:
process_payment(payload)
except Exception as e:
client.capture(e, context={"order_id": payload["id"]})
raise
async def handler(request):
try:
await process_payment(payload)
except Exception as e:
await client.capture_async(e, context={"order_id": payload["id"]})
raise
client = AfenClient(
api_url="http://localhost:3000",
api_key="your-api-token",
service_name="my-service",
auto_capture=False,
)
# settings.py
MIDDLEWARE = [
"afen.integrations.django.AfenMiddleware",
...
]
AFEN = {
"API_URL": "http://localhost:3000",
"API_KEY": "your-api-token",
"SERVICE_NAME": "my-django-app",
}
Captures all unhandled Django exceptions and attaches request.path, request.method, and response status as context.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
api_url | str | ✓ | — | Afen server URL |
api_key | str | ✓ | — | API key |
service_name | str | ✓ | — | Identifies the source service |
environment | str | "development" | Deployment environment | |
release | str | None | Release or version tag | |
auto_capture | bool | True | Register global exception hook | |
timeout | int | 5 | Request timeout in seconds |
requests ≥ 2.28.0MIT © Anamn
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.2 | 15 Jun 2026 | 1 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:f82e543a127a4b2344b7b3701932c120c2af599413a96ee84db3ddffc857b0f7