Skip to main content

Python Integrations for airbrake.io

Project description

Airbrake python notifier integrations
=====================================

<img src="http://f.cl.ly/items/3Z1A202C1U2j3E1O1N0n/python%2009.19.32.jpg" width=800px>

* [Airbrake Python Integrations README](https://github.com/airbrake/airbrake-python-integrations)
* [Airbrake Python README](https://github.com/airbrake/airbrake-python)

Integrations built on top of the airbrake python notifier for quick use with popular frameworks and libraries.

### Introduction

[Airbrake](https://airbrake.io/) is an online tool that provides robust exception
tracking in any of your Python applications. In doing so, it allows you to easily
review errors, tie an error to an individual piece of code, and trace the cause
back to recent changes. The Airbrake dashboard provides easy categorization,
searching, and prioritization of exceptions so that when errors occur, your team
can quickly determine the root cause.

### Key features

This library is built on top of [Airbrake Python](https://github.com/airbrake/airbrake-python). The difference
between _Airbrake Python_ and _Airbrake Python Integrations_ is that the
`airbrake-integrations` package is just a collection of integrations
with frameworks or other libraries. The `airbrake` package is the core library
that performs exception sending and other heavy lifting.

Normally, you just need to depend on this package, select the integration you are
interested in and follow the instructions for it. If the framework or
application you use does not have an integration available, you can depend on
the `airbrake` package and ignore this package entirely.

The list of integrations that are available in this package includes:

* Django
* Flask
* Twisted

### Installation

To install airbrake-integrations, run:
```bash
pip install airbrake-integrations
```

It's highly suggested that you add the package to your `requirements.txt` file:

```bash
pip freeze > requirements.txt
```

### Configuration

#### Django

To install the middleware and catch exceptions in your views:

- Add the following to your `settings.py` file; replacing the value with your
project's id and key:

```python
AIRBAKE = {
"PROJECT_ID": 123,
"API_KEY": "123abcde",
"ENVIRONMENT": "test"
}
```

- Add the middleware to your `settings.py` file; making sure that the
airbrake middleware is at the top of the list. Django processes middleware
in order from the end of this list to start, so placing it at the end will
catch all exceptions before it.

```python
MIDDLEWARE = [
'airbrake_integrations.django.middleware.AirbrakeNotifierMiddleware',
...
]
```

Note that any middleware that catches exceptions and does not allow them to
flow through will not be sent to airbrake. It's important to make sure any
middleware that also process exceptions will raise the original exception:

```python
def process_exception(self, request, exception):
raise exception
```

An example django app can be found in /examples/django

#### Flask

To catch exceptions, use the Airbrake extension:

Make sure the airbrake configuration fields are set:
```
AIRBRAKE_PROJECT_ID = 123456
AIRBRAKE_API_KEY = '1290180gsdf8snfaslfa0'
AIRBRAKE_ENVIRONMENT = "production"
```

And then install the extension!
```python
from airbrake_integrations.flask.app import AirbrakeApp

app = Flask(__name__)
app.config.from_pyfile('config.cfg')
ab = AirbrakeApp(app)
```

An example flask app can be found in /examples/flask

To run the example:
```bash
export FLASK_APP=example.py
flask run
```

#### Twisted

```python
from airbrake_integrations.twisted.observer import AirbrakeLogObserver
from twisted.logger import globalLogBeginner, Logger

settings = {
"AIRBRAKE": {
"PROJECT_ID": 1234,
"API_KEY": "1234567890asdfghjkl"
}
}

observers = [AirbrakeLogObserver(settings)]

globalLogBeginner.beginLoggingTo(observers, redirectStandardIO=False)

log = Logger()
try:
raise Exception("A gremlin in the system is angry")
except:
log.failure("Error")
```

This creates an observer that looks the `globalLogPublisher` twisted object, and checks all events for any possible exceptions.

An example flask app can be found in /examples/twisted


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airbrake-integrations-0.1.3.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

airbrake_integrations-0.1.3-py2.py3-none-any.whl (10.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file airbrake-integrations-0.1.3.tar.gz.

File metadata

  • Download URL: airbrake-integrations-0.1.3.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for airbrake-integrations-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ec967235a93dd59ffe3b8430158091401228d1e6283330510881e31537c3a2ba
MD5 3edc45413ea05296ef2ede915033b28c
BLAKE2b-256 a943d1e8999c3c4df0118dfe49a77df019b33df9bbc25f76a2005a0f21f00fce

See more details on using hashes here.

File details

Details for the file airbrake_integrations-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: airbrake_integrations-0.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for airbrake_integrations-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 15d30ec4b05aa0dcf5f66c9ebe757a3e767d145557fb8fc1a7ac9ffbdeb02bbd
MD5 ffd99393828fd8d56f18273a23bc2d4f
BLAKE2b-256 c4384816f2e4e1da38a8d6945655bc7c3b039d58d8a1fbdb00cc8a12ea66ef59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page