CherryPy

Installing Airbrake in a CherryPy application

CherryPy

The pybrake package makes it quick and easy to monitor your CherryPy app’s performance. It only takes a few minutes to start collecting real performance data so let’s jump right in!

Key Features


Installation & Configuration

Set up the Pybrake’s middleware and project config for your web application

Step 1: Install the latest version of pybrake

Airbrake for CherryPy uses our official Python notifier pybrake. To install run:

pip install -U pybrake

Step 2: Configure the Pybrake CherryPy middleware

First, import CherryPy middleware from the pybrake package

from pybrake.middleware.cherrypy import PybrakePlugin
"""
The plugin is registered to the CherryPy engine and therefore
is part of the bus (the engine *is* a bus) registry.
We use this plugin to create the notifier instance and apply patch
for Error notification and APM.
        
:param project_id: Airbrake project id
:param project_key: Airbrake project key
:param kw: Addition pybrake parameters like performance_stats, 
        queue_stats, etc.
"""

Next, add configuration parameters

config = {
    "PYBRAKE": {
        'project_id': 999999,
        'project_key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        'environment': 'development'
    },
}

Finally, subscribe the pybrake’s CherryPy middleware in your application

    pybrake_plugin = PybrakePlugin(
        cherrypy.engine, **config.get('PYBRAKE')
    )
    pybrake_plugin.subscribe()
    pybrake_plugin.create()

Now you are ready to start reporting errors and performance monitoring to Airbrake from your CherryPy app. Please look into sample example to get more idea.


Additional Settings

Please visit our Pybrake overview for details on useful features like:


Troubleshoot

If you have any questions or concerns, please address them here.