Official Alby error tracking SDK for Python.
Project description
alby-report
Official Alby error-tracking SDK for Python.
Captures uncaught exceptions and anything you explicitly report, then ships them to your Alby project where an AI agent can auto-open a fix task.
Zero runtime dependencies. Python 3.8+.
Install
pip install alby-report
Use
import os
import alby
alby.init(
dsn=os.environ['ALBY_DSN'], # https://<key>@alby.sh/ingest/v1/<app-id>
release='1.4.2',
environment='production',
)
# Uncaught exceptions are sent automatically (sys.excepthook + threading.excepthook).
# Manual report:
try:
do_thing()
except Exception as exc:
alby.capture_exception(exc)
# Non-error events:
alby.capture_message('Failed to acquire lease', level='warning')
# Enrich:
alby.set_user({'id': 'u_412', 'email': 'ada@example.com'})
alby.set_tag('region', 'eu-west-3')
alby.set_context('billing_tenant', {'plan': 'pro', 'seats': 12})
alby.add_breadcrumb({'type': 'http', 'message': 'GET /api/orders/42'})
# Decorator:
@alby.monitor
def charge_customer(customer_id: str) -> None:
...
# Before exit (e.g. in a short-lived CLI):
alby.flush(2000)
Options
| Option | Type | Default | Notes |
|---|---|---|---|
dsn |
str |
- (required) | The DSN from your Alby app settings. |
release |
str |
'' |
Your build version. Enables release tracking / auto-resolve. |
environment |
str |
$ALBY_ENV or 'production' |
production / staging / dev / anything. |
sample_rate |
float |
1.0 |
Fraction of events actually sent. |
platform |
str |
'python' |
Override auto-detection. |
server_name |
str |
socket.gethostname() |
Attached to every event. |
auto_register |
bool |
True |
Install sys.excepthook + threading.excepthook handlers. |
transport |
Transport |
HttpTransport |
Custom delivery (tests, batching, filesystem spool). |
debug |
bool |
False |
Log SDK diagnostics to stderr. |
max_breadcrumbs |
int |
100 |
Ring buffer size. |
Framework integrations
Django
In settings.py:
MIDDLEWARE = [
# ... Django's own middleware ...
'alby.integrations.django.AlbyMiddleware',
]
Initialise Alby early in your app setup (e.g. settings.py or wsgi.py).
Flask
from flask import Flask
from alby.integrations.flask import init_app as alby_init_app
app = Flask(__name__)
alby_init_app(app)
FastAPI / Starlette
from fastapi import FastAPI
from alby.integrations.fastapi import AlbyMiddleware
app = FastAPI()
app.add_middleware(AlbyMiddleware)
Transport
urllib.requestunder the hood (zero deps).- Non-blocking: a bounded
queue.Queue(maxsize=100)plus a daemon worker thread.capture_*only enqueues. - Retries: 3 attempts at 1s / 5s / 15s backoff.
- Honours
Retry-Afteron HTTP 429. - Best-effort drain on interpreter exit via
atexit.
For synchronous delivery, inject your own Transport via alby.init(transport=...).
Wire protocol
This SDK speaks the Alby Ingest Protocol v1. If you're writing a new SDK (different runtime, different language) start there.
Links
- Website: alby.sh
- Report issues: GitHub Issues
- Other SDKs: alby-sdk-js · alby-sdk-browser · alby-sdk-php
License
MIT (c) Alby.
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 alby_report-0.1.0.tar.gz.
File metadata
- Download URL: alby_report-0.1.0.tar.gz
- Upload date:
- Size: 20.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 |
0a41503c63a763a9c0b464e5f3ed87749cd83754608d6640d1f42aa5e25655a1
|
|
| MD5 |
ff91448c20b1ec211cbb2ee32926f636
|
|
| BLAKE2b-256 |
b0d9ecd1c6c67157c3d2602293de3a632d85e23edae12540ff566b04474a5cf9
|
Provenance
The following attestation bundles were made for alby_report-0.1.0.tar.gz:
Publisher:
ci.yml on alby-sh/alby-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alby_report-0.1.0.tar.gz -
Subject digest:
0a41503c63a763a9c0b464e5f3ed87749cd83754608d6640d1f42aa5e25655a1 - Sigstore transparency entry: 1342284041
- Sigstore integration time:
-
Permalink:
alby-sh/alby-sdk-python@1e563f81e38aad1ae58433896d010a9de960506b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/alby-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@1e563f81e38aad1ae58433896d010a9de960506b -
Trigger Event:
push
-
Statement type:
File details
Details for the file alby_report-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alby_report-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.6 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 |
2e118e26669e0a76ce54cab66556f4a934c35d3458c843519f0bbd54f1e2543e
|
|
| MD5 |
c7f979849e94077471c726d85b65d1a0
|
|
| BLAKE2b-256 |
ac0a79acc89012a6124591174918baa6deb0c7492d96c0c9146c5c006ffb0d4e
|
Provenance
The following attestation bundles were made for alby_report-0.1.0-py3-none-any.whl:
Publisher:
ci.yml on alby-sh/alby-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alby_report-0.1.0-py3-none-any.whl -
Subject digest:
2e118e26669e0a76ce54cab66556f4a934c35d3458c843519f0bbd54f1e2543e - Sigstore transparency entry: 1342284049
- Sigstore integration time:
-
Permalink:
alby-sh/alby-sdk-python@1e563f81e38aad1ae58433896d010a9de960506b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/alby-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@1e563f81e38aad1ae58433896d010a9de960506b -
Trigger Event:
push
-
Statement type: