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. - The request ID: errors and transactions have a
request_idtag, the ID of the request in the app's logs and in the response'sX-Request-IDheader, so you can go from a report to the log lines of its request. - 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.
The values of Proper's session and sign-in cookies (_session and _auth), and of any form field with "password" in its name, are never sent, whatever the data scrubbing settings of your Sentry project.
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 org: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.2.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 | Provenance | Actions |
|---|---|---|---|---|
| proper_sentry-0.2.0.tar.gz | 13.2 kB | Without provenance | Details for proper_sentry-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| proper_sentry-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for proper_sentry-0.2.0-py3-none-any.whl |
Total release size: 20.0 kB
Release files / proper_sentry-0.2.0.tar.gz
| Download URL | proper_sentry-0.2.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
608f1071c8859f716cf13677619af108116631a1a5bb41eb9ee30b396c6bd395
|
|
BLAKE2b-256 checksum How to use checksums |
ac4f8939e37ba6c2f60a81a1d4ca27504753c1e564ded5de1af2d8824ae7bfc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","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.2.0-py3-none-any.whl
| Download URL | proper_sentry-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66efd3d9221aa2ce62bd4fbc0d9d1271ba8744b4c0c1f4620cf3da1368b47a10
|
|
BLAKE2b-256 checksum How to use checksums |
fe1114b7e944725241bb79086fd808fbb1459d3381389be0a9cd6917c0772115
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","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}
|
Security for proper-sentry 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.