Integrating Rollbar

Rollbar plays the same role as Sentry. Integration is equally as simple. We will still use a decorator for our handler functions, but we'll need a different library with Rollbar. Rollbar provides an official library for Python (https://github.com/rollbar/pyrollbar) and many other languages.

The setup changes slightly with pyrollbar, but it's nothing too complicated. The following code block shows how to set up an AWS Lambda function for error tracking with Rollbar.

import rollbartoken = os.getenv('ROLLBAR_KEY', 'missing_api_key')rollbar.init(token, os.getenv('ENV', 'dev'))@rollbar.lambda_functiondef divide(event, context):    # code

When we hit an exception, information is delivered to Rollbar. Again, an email notification ...

Get Serverless Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.