Skip to content

Instantly share code, notes, and snippets.

@mmcdaris
Last active August 29, 2015 14:27
Show Gist options
  • Save mmcdaris/edd751e0da7045e7133f to your computer and use it in GitHub Desktop.
Save mmcdaris/edd751e0da7045e7133f to your computer and use it in GitHub Desktop.
airbarke-django example

Install airbrake-django from github using pip

pip install git+https://github.com/airbrake/airbrake-django.git

Add airbrake to your settings.py

Make a section in your settings.py for the airbrake settings for your project:

# Airbrake settings
AIRBRAKE = {
    'API_KEY': 'YOUR_PROJECT_API_KEY',
    'USE_SSL': True,
    'TIMEOUT': 5,
    'ENVIRONMENT': 'production',
}

Add airbrake to INSTALLED_APPS in your settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    # ...
    'airbrake'
)

sending errors to airbrake

This is basic usage for the airbrake Client

# hello.py
from django.http import HttpResponse
from airbrake.utils.client import Client

def hello_errors(request):
    try:
        1/0
    except Exception as error:
        airbrake = Client()
        airbrake.notify(error, request)

    return HttpResponse("Hello Erorrs")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment