https://github.com/programmer-ke/dj-datadog
A simple Django middleware for submitting timings and exceptions to Datadog.
https://github.com/programmer-ke/dj-datadog
Last synced: 11 months ago
JSON representation
A simple Django middleware for submitting timings and exceptions to Datadog.
- Host: GitHub
- URL: https://github.com/programmer-ke/dj-datadog
- Owner: programmer-ke
- License: other
- Created: 2016-07-05T08:32:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-01T09:03:52.000Z (over 9 years ago)
- Last Synced: 2025-01-03T21:43:36.961Z (over 1 year ago)
- Language: Python
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Datadog
A simple Django middleware for submitting timings and exceptions to Datadog.
This is a derivative work of conorbranagan's package
https://github.com/conorbranagan/django-datadog updated to use the latest python
datadog API.
## Installation
Download the code into your project and install it.
```bash
git clone git://github.com/krmboya/dj-datadog.git
cd dj-datadog
python setup.py install
```
Add `dj_datadog` to your list of installed apps.
```python
INSTALLED_APPS += ('dj_datadog',)
```
Add the following configuration to your projects' `settings.py` file:
```python
DATADOG_API_KEY = 'YOUR_API_KEY'
DATADOG_APP_KEY = 'YOUR_APP_KEY'
DATADOG_APP_NAME = 'my_app' # Used to namespace metric names
```
The API and app keys can be found at https://app.datadoghq.com/account/settings#api
Add the Datadog request handler to your middleware in `settings.py`.
```python
MIDDLEWARE_CLASSES += ('dj_datadog.middleware.DatadogMiddleware',)
```
If you want log the wsgi process memory spikes per request/response cycle, add
the memory profiling middleware (see [this link][1] for more info)
[1]: https://stackoverflow.com/a/12254394
```python
MIDDLEWARE_CLASSES += ('dj_datadog.middleware.MemoryUsageMiddleware',)
```
For local development, you can add this to your `settings.py` file:
```python
DJ_DATADOG_DEBUG = True
```
The metrics will then be logged locally instead of making requests to Datadog.
## Usage
Once the middlewhere installed, you'll start receiving events in your Datadog
stream in the case of an app exception.
You will also have the following new metrics available:
- `my_app.request_time.{avg,max,min}` in seconds
- `my_app.errors`
- `my_app.memory_usage` in MB (if the memory usage middleware is used)
Metrics are tagged with `path:/path/to/view`
Note: `my_app` will be replaced by whatever value you give for `DATADOG_APP_NAME`.