Package: airbrake-integrations
Airbrake python notifier integrationsAirbrake Python Integrations READMEAirbrake Python READMEIntegrations built on top of the airbrake python notifier for quick use with popular frameworks and libraries.IntroductionAirbrakeis 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 featuresThis library is built on top ofAirbrake Python. The difference
betweenAirbrake PythonandAirbrake Python Integrationsis that theairbrake-integrationspackage is just a collection of integrations
with frameworks or other libraries. Theairbrakepackage 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
theairbrakepackage and ignore this package entirely.The list of integrations that are available in this package includes:DjangoFlaskTwistedInstallationTo install airbrake-integrations, run:pipinstallairbrake-integrationsIt's highly suggested that you add the package to yourrequirements.txtfile:pipfreeze>requirements.txtConfigurationDjangoTo install the middleware and catch exceptions in your views:Add the following to yoursettings.pyfile; replacing the value with your
project's id and key:AIRBAKE={"PROJECT_ID":123,"API_KEY":"123abcde","ENVIRONMENT":"test"}Add the middleware to yoursettings.pyfile; 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:defprocess_exception(self,request,exception):raiseexceptionAn example django app can be found in /examples/djangoFlaskTo 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!fromairbrake_integrations.flask.appimportAirbrakeAppapp=Flask(__name__)app.config.from_pyfile('config.cfg')ab=AirbrakeApp(app)An example flask app can be found in /examples/flaskTo run the example:exportFLASK_APP=example.py
flaskrunTwistedfromairbrake_integrations.twisted.observerimportAirbrakeLogObserverfromtwisted.loggerimportglobalLogBeginner,Loggersettings={"AIRBRAKE":{"PROJECT_ID":1234,"API_KEY":"1234567890asdfghjkl"}}observers=[AirbrakeLogObserver(settings)]globalLogBeginner.beginLoggingTo(observers,redirectStandardIO=False)log=Logger()try:raiseException("A gremlin in the system is angry")except:log.failure("Error")This creates an observer that looks theglobalLogPublishertwisted object, and checks all events for any possible exceptions.An example flask app can be found in /examples/twisted