Skip to main content

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 the sentry-trace and baggage headers.
  • 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 to False to 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.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proper-sentry 0.1.1
File Size Uploaded
proper_sentry-0.1.1.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for proper-sentry 0.1.1
File Interpreter ABI Platform
proper_sentry-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / proper_sentry-0.1.1.tar.gz

Download URL proper_sentry-0.1.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b4675ed96d2ce3dd8695bf846799206afce9457639314637ee2f3ab124c28451
BLAKE2b-256 checksum
How to use checksums
c2ec1a66ed76dbe20975b4a68bda715ba04cfa6ee34f7eee051e3596c57aff73
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.1-py3-none-any.whl

Download URL proper_sentry-0.1.1-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61f4b94090ee7eac5bf4f946749e1a434dd887f4d86c0e5e28ccbeb2a1345544
BLAKE2b-256 checksum
How to use checksums
1dba5b0af670b285ab6189426c1f8b183d970578e5606717823d9ec07e7f455d
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 history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page