Masonite

Installing Airbrake in a Masonite application

Masonite

The pybrake package makes it quick and easy to monitor your Masonite 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 Masonite uses our official Python notifier pybrake. To install run:

pip install -U pybrake

Step 2: Configure the Pybrake Masonite middleware

First, configure parameters in config/application.py:

PYBRAKE = {
    'project_id': 999999,
    'project_key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'environment': 'test'
}

Next, register the Pybrake notifier and PybrakeErrorListener in app/providers/AppProvide.py

from pybrake.middleware.masonite import (
    PybrakeNotifier, PybrakeErrorListener, PybrakeRouteMiddleware
)

class AppProvider(Provider):
    def __init__(self, application):
        self.application = application

    def register(self):
        self.application.bind(
            "pybrake", PybrakeNotifier(self.application)
        )
        self.application.make("middleware").add([PybrakeRouteMiddleware])
        self.application.make("event").listen("masonite.exception.*",
                                              [PybrakeErrorListener])
    ...

To monitor schedule tasks, utilize schedule_task decorator

import time
from masonite.scheduling import Task
from pybrake.middleware.masonite import schedule_task

class WeatherTest(Task):

    name = "WeatherTest"

    @schedule_task
    def handle(self):
        time.sleep(10)

Now you are ready to start reporting errors and performance monitoring to Airbrake from your Masonite 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.