Skip to main content

A Django app to initialize Sentry client for your Django applications

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj-sentry-0.2.0.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

dj_sentry-0.2.0-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page