Skip to content

TKim18/airbrake-django

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

When I went to implement Airbrake in Sprint.ly I found two projects that looked like they might do the trick: django-airbrake, which was forked from the dormant django-hoptoad and Pytoad which wasn't made for Django. In the end, I decided to use bits and pieces of the two as the older django-airbrake wasn't working with the newer API and Pytoad didn't have any Django sugar.

Install airbrake-django from github using pip

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

Configure airbrake in your settings.py

To configure airbrake you will need to add airbrake to your INSTALLED_APPS and create the AIRBRAKE dictionary.

Add airbrake to INSTALLED_APPS in your settings.py

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

Create the AIRBRAKE dictionary in your settings.py for project:

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

Then just restart your server!

Manually sending errors to airbrake

This example illustrates sending an error to Airbrake in a try catch.

# 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")

About

A Django project for Airbrake

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%