Report exceptions from any Django site to Google Cloud Stackdriver Error Reporting
- Free software: MIT license
- Report exceptions from any Django site to Google Cloud Stackdriver Error Reporting
- Optional dependency on django-ipware for logging of IP addresses
- Configure your app to user Google Cloud project:
- Enabled the Error Reporting api as per https://cloud.google.com/error-reporting/docs/setup/python
- Set up the required Google IAM credentials - eg set the environment variable GOOGLE_APPLICATION_CREDENTIALS as the path to a service account JSON file, for an account that has the "Errors Writer" permission.
Install the package:
pip install dj_cloud_error
Enable the provided exception handler by setting
handler500
in your Django project's rooturls.py
:# in myproject/urls.py import dj_cloud_error handler500 = dj_cloud_error.handler500
Note: handler500
is only used if DEBUG = False
in django settings.
To disable error reporting (eg in your CI/CD environment), add this to your django settings:
# in myproject/settings/test.py CLOUD_ERROR_REPORTING_DISABLED = True
To configure the name under which the errors appear in add this to your django settings:
CLOUD_ERROR_REPORTING_SERVICE_NAME = "myservice" # defaults to "python"
If django-ipware is installed it's used to log the client IP address, it can be installed as follows:
pip install dj_cloud_error[ip]
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.