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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dj-sentry-0.2.0.tar.gz.
File metadata
- Download URL: dj-sentry-0.2.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.5 Linux/5.18.2-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f7ae379c5aab53e9212b754537b0f52e6b488fd4219949f8684f059f9fb655
|
|
| MD5 |
3c6fb0d9eba84889b39353d50c4e9726
|
|
| BLAKE2b-256 |
14c89dd733db276110f6b5609a86043ecc32e65b759d56836c3f43a4aec3fc97
|
File details
Details for the file dj_sentry-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dj_sentry-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.5 Linux/5.18.2-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797b07635c30161c56b3cb5cf83b36a21c4f467fa549e269bfc808837ca056fe
|
|
| MD5 |
f99f92d758f0ae05f80cc8872576da66
|
|
| BLAKE2b-256 |
039487f6e879eb1b5f3f0f5d439c19be7f924079e891e6251440e109ee04b9da
|