Git Product home page Git Product logo

airbrake-django's Introduction

Note. Python 3.4+ users are strongly advised to try new Airbrake Python notifier which supports async API and code hunks. Python 2.7 users should continue to use this notifier.

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',
    'TIMEOUT': 5,
    'ENVIRONMENT': 'production',
    'FILTERED_EXCEPTIONS': (Http404,)
}

Then just restart your server!

Automatically sending errors to airbrake

New-style (introduced in Django 1.10):
MIDDLEWARE = (
    ...,
    'airbrake.middleware.AirbrakeNotifierMiddleware'
)
Old-style:
MIDDLEWARE_CLASSES = (
    ...,
    'airbrake.middleware.AirbrakeNotifierMiddleware'
)

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

airbrake-django's People

Contributors

ashishgandhi avatar benpetty avatar joestump avatar kyrylo avatar lseelenbinder avatar mmcdaris avatar mvaerle avatar peleccom avatar phumpal avatar rynbrd avatar rynmlng avatar vmihailenco avatar zachgoldstein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.