proper-sentry
Report the errors and the performance of a Proper app to Sentry.
uv add proper-sentry
Usage
Add a SENTRY dict to your config. It takes the same options as sentry_sdk.init():
SENTRY = {
"dsn": "https://<key>@<org>.ingest.sentry.io/<project>",
"environment": "production",
"traces_sample_rate": 0.1,
}
Then instrument the app, right after creating it:
from proper import App
from proper_sentry import instrument
app = App(__name__, config=config)
instrument(app)
Leave SENTRY out of your development config and nothing is reported.
If you'd rather start Sentry yourself, call sentry_sdk.init(...) and then instrument(app) without a SENTRY config.
What gets reported
- Errors: every request that ends in a server error (5xx), with the request's method, URL, headers and form fields. Errors that become a 4xx page (not found, forbidden, invalid CSRF token...) aren't reported.
- Performance: each request is a transaction, named after its controller action (
myapp.controllers.posts.PostsController.show), with a span for every SQL query. Traces from other services continue through thesentry-traceandbaggageheaders. - Background tasks: Sentry's own Huey integration reports the tasks of the queue. It turns on by itself.
With "send_default_pii": True in SENTRY, the reports also include the cookies, the IP address, and the id, email and login of current.user.
Options
instrument(app, transaction_style="url", trace_sql=False)
transaction_style:"endpoint"(the default) names transactions after the controller action;"url"uses the route path (/posts/:id).trace_sql: set toFalseto skip the SQL spans and breadcrumbs.
Not supported yet
- WebSocket channels.
- Sentry's span streaming mode (
trace_lifecycle="stream"): errors are still reported, but no transactions are sent.
Development
make install
make test
make lint
tests/test_e2e.py sends real events to a Sentry project and reads them back through the Sentry API. It's skipped unless these environment variables are set:
export SENTRY_DSN=... # DSN of a project used only for tests
export SENTRY_AUTH_TOKEN=... # a token with event:read and project:read
export SENTRY_ORG=... # the organization slug
make e2e
It takes a minute or two, while Sentry indexes the events.
Metadata
Release files for proper-sentry 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| proper_sentry-0.1.0.tar.gz | 11.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| proper_sentry-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.2 kB
Release files / proper_sentry-0.1.0.tar.gz
| Download URL | proper_sentry-0.1.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e9ef19439a3698a107c721dfcef1c34815f9bbec524265ef68bcdc324e9eb44
|
|
BLAKE2b-256 checksum How to use checksums |
e119588841fd8c6ba579e69ca2b722b90683160bb4d2500395281ffc007e6fde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / proper_sentry-0.1.0-py3-none-any.whl
| Download URL | proper_sentry-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fc8a7b270d594c69ddac321673f1f2364bd8e780e09c92e5a2e396f96abe336
|
|
BLAKE2b-256 checksum How to use checksums |
0be6447ee615f765d9e4c19fe3bdf0c1b75b10dd954b8c285589715b7f3eca9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|