Skip to main content

Dj_sentry

This Django application intialize Sentry SDK to your Django application.

How to install

You can install this packaging by using:

pip install dj_sentry

Alternatively, if you use a package manager, for example Poetry, you can use:

poetry add dj_sentry

How to configure

In your settingsfiles, add the following settings to configure the Sentry SDK according with your needs:

Setting Type Description
SENTRY_DSN str mandatory Sentry project DSN.
SENTRY_ENVIRONMENT str mandatory Environment where the application is running (for example: production, pre-production, staging)
SENTRY_APP_PACKAGE_NAME str optional Package name of your application¹.
SENTRY_EXTRA_INTEGRATIONS list optional List of Sentry integrations you want to use (in addition of the Django integration already set-up)
SENTRY_EXTRA_OPTS dict optional Dict with additionnal settings for configuring the Sentry client. See Sentry client configuration

¹: We use pkg_resources from Setuptools to get the package version of your application and send it on every events. This setting is optional but highly recommended.

By default, the setting traces_sample_rate send_default_pii have the following default values

Setting Value
traces_sample_rate 0 (no tracing samples sent to Sentry)
send_default_pii True (send user information in events)

You can change de values of those settings by using the SENTRY_EXTRA_OPTS setting. For example, to disable the setting that send user informations:

SENTRY_EXTRA_OPTS = {
    "send_default_pii": False,  # Do not send user information in Sentry events
}

Here's an example of valid configuration:

from sentry_sdk.integrations.redis import RedisIntegration
from company_cms.utils.sentry import before_send_filter

# Your Django configuration ...

SENTRY_DSN = "https://<token>@sentry.company.com/<project_id>"
SENTRY_ENVIRONMENT = "production"
SENTRY_APP_PACKAGE_NAME = "company_cms"
SENTRY_EXTRA_INTEGRATIONS = [RedisIntegration()]  # Add Redis integration to Sentry SDK
SENTRY_EXTRA_OPTS = {
    "before_send": before_send_filter,  # Do some events filtering before sending them (see: https://docs.sentry.io/platforms/python/configuration/filtering/)
}

# Your Django configuration ...

License

This project is released under BSD-3 Clause.

Metadata

Release files for dj-sentry 0.3.0

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

Source distribution (sdist)

Source distribution for dj-sentry 0.3.0
File Size Uploaded
dj_sentry-0.3.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-sentry 0.3.0
File Interpreter ABI Platform
dj_sentry-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / dj_sentry-0.3.0.tar.gz

Download URL dj_sentry-0.3.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3d7a8b40ae7a211304e6ce20aa7e1bcc70853b415e3397418c6451807613bcb6
BLAKE2b-256 checksum
How to use checksums
6234f30f7afac9dc10fa9bc746702da61a59754421187546e3612beaf360f1e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.2 CPython/3.12.14 Linux/6.17.0-1022-azure

Release files / dj_sentry-0.3.0-py3-none-any.whl

Download URL dj_sentry-0.3.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2db35a81f5765bfbfe8308925686bd24fb10ae8639c76f5c2f300fa357fd4f5
BLAKE2b-256 checksum
How to use checksums
7bcabad6bcb1fade9f666ee6f987b89f55d1d158c494b74cce9190eaa6cd5620
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.2 CPython/3.12.14 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

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