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.1.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_sentry-0.1.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file dj-sentry-0.1.1.tar.gz.

File metadata

  • Download URL: dj-sentry-0.1.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.7 Linux/5.15.2-arch1-1

File hashes

Hashes for dj-sentry-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a6530ee9e2b8cb55dd4ee0a07452ef94067650a71a0c16192c26e6f2dbee8cac
MD5 25445d8cdbc0e419c656feaedf483fc6
BLAKE2b-256 ca1a83924e0f10db8cd97f3e922dda0cfdea35853e09a009f4e1ce30ff30d32b

See more details on using hashes here.

File details

Details for the file dj_sentry-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dj_sentry-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.7 Linux/5.15.2-arch1-1

File hashes

Hashes for dj_sentry-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1086793c114c1b4688023f39c7315bbdd09bdaff646e53c1b0bb0f14c7ba8c68
MD5 34a879a91036049db8c793256cb01284
BLAKE2b-256 566eb21d3dbc1b89cbe201659c8c0b1e6bea18de7148804186453d5274e8f5a0

See more details on using hashes here.

Supported by

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