Python Integrations for airbrake.io
Project description
Airbrake python notifier integrations
Integrations built on top of the airbrake python notifier for quick use with popular frameworks and libraries.
Introduction
Airbrake 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. 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:
pip install airbrake-integrations
It's highly suggested that you add the package to your requirements.txt
file:
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:
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.
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:
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!
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:
export FLASK_APP=example.py
flask run
Twisted
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
Built Distribution
File details
Details for the file airbrake-integrations-0.1.4.tar.gz
.
File metadata
- Download URL: airbrake-integrations-0.1.4.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3be575ea40f7a8d7f2b33da240b9f129cdc3ee4ae7487a46b17852ab156c8655 |
|
MD5 | aa6b009b882cc298de9716bf75a49b9f |
|
BLAKE2b-256 | 14a930241b9a68261752e1e99d311925203d1f1eaf059b96b5af266edab15a0a |
File details
Details for the file airbrake_integrations-0.1.4-py2.py3-none-any.whl
.
File metadata
- Download URL: airbrake_integrations-0.1.4-py2.py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f406012459e44ef8928569bf463c10eef9f8a2ae5e968cd0cc66e54060f5cf7 |
|
MD5 | a663e34a6c93dc0a00d0eac7cec8559b |
|
BLAKE2b-256 | 054749e3d2a21633bc274ebb7b511db285f66756c79494ddd5ce1a9b011d6cdc |