Easy Django-Sentry integration via Django settings.
Project description
# Sentry Django Settings
This is a package for Django that allows you to add Sentry integration by adding a Django setting.
## Installation
`pip install sentry_django_settings`
Add `sentry_django_settings.apps.Sentry` to your `INSTALLED_APPS`.
```python
INSTALLED_APPS = [
# ...
'sentry_django_settings.apps.Sentry',
# ...
]
```
Add a setting like the following to your `settings.py` file:
```python
SENTRY = {
'enabled': True,
'dsn': "https://2e2ac79f64d34e4b85c3a3173e343464@sentry.mysite.com/5",
'environment': "dev", # Optional
'release': '1.0', # Optional
}
```
`enabled` is a boolean if Sentry should be initialized or not.
To find the DSN in Sentry:
- Go to the project settings in Sentry
- Under `Data`, select `Error Tracking`
- Click "Get your DSN."
- Use the "Public DSN" in all cases.
The `environment` should be appropriate to environment where the server will be running.
The `release` can be any string, but a good option is for it to be either the Git `sha`, or a deployment variable, such as from Bamboo.
The following recommended code requires the GitPython package: `pip install gitpython`. It attempts to get the Git `sha` from the Git repo, if it exists, otherwise it gets it from the Bamboo deployment variable `bamboo_planRepository_revision`.
```python
import os
import git
def get_release():
# Get Git sha, if it's a Git repo.
try:
repo = git.Repo(search_parent_directories=True)
return repo.head.object.hexsha
except git.InvalidGitRepositoryError:
pass
# Get the release from the environment
return os.environ.get("bamboo_planRepository_revision")
```
This is a package for Django that allows you to add Sentry integration by adding a Django setting.
## Installation
`pip install sentry_django_settings`
Add `sentry_django_settings.apps.Sentry` to your `INSTALLED_APPS`.
```python
INSTALLED_APPS = [
# ...
'sentry_django_settings.apps.Sentry',
# ...
]
```
Add a setting like the following to your `settings.py` file:
```python
SENTRY = {
'enabled': True,
'dsn': "https://2e2ac79f64d34e4b85c3a3173e343464@sentry.mysite.com/5",
'environment': "dev", # Optional
'release': '1.0', # Optional
}
```
`enabled` is a boolean if Sentry should be initialized or not.
To find the DSN in Sentry:
- Go to the project settings in Sentry
- Under `Data`, select `Error Tracking`
- Click "Get your DSN."
- Use the "Public DSN" in all cases.
The `environment` should be appropriate to environment where the server will be running.
The `release` can be any string, but a good option is for it to be either the Git `sha`, or a deployment variable, such as from Bamboo.
The following recommended code requires the GitPython package: `pip install gitpython`. It attempts to get the Git `sha` from the Git repo, if it exists, otherwise it gets it from the Bamboo deployment variable `bamboo_planRepository_revision`.
```python
import os
import git
def get_release():
# Get Git sha, if it's a Git repo.
try:
repo = git.Repo(search_parent_directories=True)
return repo.head.object.hexsha
except git.InvalidGitRepositoryError:
pass
# Get the release from the environment
return os.environ.get("bamboo_planRepository_revision")
```
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
Built Distribution
Close
Hashes for sentry_django_settings-0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f33fd4d2eec8c3ebcad34cdc3c9daa69e98a842833afe6e9c6bf39e61404b75 |
|
MD5 | 38127af384b4f74b2800cbf8eecb7e29 |
|
BLAKE2b-256 | a9cccdb60c03dbf7e18a8d5b1342c61b6f2b2b2a051f3d9fcd65178e5a36862e |
Close
Hashes for sentry_django_settings-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cbcd8bfddf0d862cd69b6d790da53f61421a6437f8f4c4a0c92790e318f95e3 |
|
MD5 | f609aef36628ec290f53c452607a53a0 |
|
BLAKE2b-256 | a509021b95e384740c71e2bb30618a887b9be03c387c90acce2b563fd50aa053 |