Documentation

Check out our guides and API reference documentation on how to use Rollbar to monitor, debug, and triage errors.

Guides & SDKs    API Reference

pyrollbar is a Python SDK for reporting exceptions, errors, and log messages to Rollbar.

Quick start

Install using pip:

pip install rollbar
import rollbar
rollbar.init('POST_SERVER_ITEM_ACCESS_TOKEN', 'production')  # access_token, environment

try:
    main_app_loop()
except IOError:
    rollbar.report_message('Got an IOError in the main loop', 'warning')
except:
    # catch-all
    rollbar.report_exc_info()
    # equivalent to rollbar.report_exc_info(sys.exc_info())

Requirements

  • Python 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 or 3.8
  • requests 0.12+
  • A Rollbar account

Configuration

Django

There are two options for installing the Rollbar middleware. Both options
require modifying your settings.py file.

The first option is to use
'rollbar.contrib.django.middleware.RollbarNotifierMiddleware' which will
report all exceptions to Rollbar including 404s. This middlware should be
placed as the last item in your middleware list which is:

  • MIDDLEWARE_CLASSES in Django 1.9 and earlier:

    MIDDLEWARE_CLASSES = [
        # ... other middleware classes ...
        'rollbar.contrib.django.middleware.RollbarNotifierMiddleware',
    ]
    
  • MIDDLEWARE in Django 1.10 and up:

    MIDDLEWARE = [
        # ... other middleware classes ...
        'rollbar.contrib.django.middleware.RollbarNotifierMiddleware',
    ]
    

The other option is to use the two separate middlewares:

  • 'rollbar.contrib.django.middleware.RollbarNotifierMiddlewareExcluding404'

  • 'rollbar.contrib.django.middleware.RollbarNotifierMiddlewareOnly404'

The Excluding404 middleware should be placed as the last item in your middleware
list, and the Only404 middleware should be placed as the first item in your
middleware list. This allows 404s to be processed by your other middlewares
before sendind an item to Rollbar. Therefore if you handle the 404 differently
in a way that returns a response early you won't end up with a Rollbar item.

Regardless of which method you use, you also should add a section to settings.py
with configuration data such as:

ROLLBAR = {
    'access_token': 'POST_SERVER_ITEM_ACCESS_TOKEN',
    'environment': 'development' if DEBUG else 'production',
    'branch': 'master',
    'root': '/absolute/path/to/code/root',
}

Additionally, you can use the key 'ignorable_404_urls' to set an iterable of regular expression
patterns to use to determine whether a 404 exception should be ignored based
on the full url path for the request. For example,

import re
ROLLBAR = {
    'access_token': 'POST_SERVER_ITEM_ACCESS_TOKEN',
    'environment': 'development' if DEBUG else 'production',
    'branch': 'master',
    'root': '/absolute/path/to/code/root',
    'ignorable_404_urls': (
        re.compile('/index\.php'),
        re.compile('/foobar'),
    ),
}

If you're using Django REST Framework and would like to have parsed POST variables placed in your output for exception handling, then add these configuration variables in settings.py:

REST_FRAMEWORK = {
    'EXCEPTION_HANDLER': 'rollbar.contrib.django_rest_framework.post_exception_handler'
}

Be sure to replace POST_SERVER_ITEM_ACCESS_TOKEN with your project's post_server_item access token, which you can find in the Rollbar.com interface.

Check out the Django example.

If you'd like to be able to use a Django LOGGING handler that could catch errors that happen outside of the middleware and ship them to Rollbar, such as in celery job queue tasks that run in the background separate from web requests, do the following:

Add this to the handlers key:

    'rollbar': {
        'filters': ['require_debug_false'],
        'access_token': 'POST_SERVER_ITEM_ACCESS_TOKEN',
        'environment': 'production',
        'class': 'rollbar.logger.RollbarHandler'
    },

Then add the handler to the loggers key values where you want it to fire off.

    'myappwithtasks': {
        'handlers': ['console', 'logfile', 'rollbar'],
        'level': 'DEBUG',
        'propagate': True,
    },

Celery

Check out the rollbar-celery-example.

To use pyrollbar with Celery in a Django app, please see this blog post written by Matt Layman which explains how to configure everything in detail.

Pyramid

In your ini file (e.g. production.ini), add rollbar.contrib.pyramid to the end of your pyramid.includes:

[app:main]
pyramid.includes =
    rollbar.contrib.pyramid

And add these rollbar configuration variables:

[app:main]
rollbar.access_token = POST_SERVER_ITEM_ACCESS_TOKEN
rollbar.environment = production
rollbar.branch = master
rollbar.root = %(here)s

Be sure to replace POST_SERVER_ITEM_ACCESS_TOKEN with your project's post_server_item access token, which you can find in the Rollbar.com interface.

The above will configure Rollbar to catch and report all exceptions that occur inside your Pyramid app. However, in order to catch exceptions in middlewares or in Pyramid itself, you will also need to wrap your app inside a pipeline with Rollbar as a filter.

To do this, first change your ini file to use a pipeline. Change this:

[app:main]
#...

To:

[pipeline:main]
pipeline =
    rollbar
    YOUR_APP_NAME

[app:YOUR_APP_NAME]
pyramid.includes =
    rollbar.contrib.pyramid

rollbar.access_token = POST_SERVER_ITEM_ACCESS_TOKEN
rollbar.environment = production
rollbar.branch = master
rollbar.root = %(here)s

[filter:rollbar]
use = egg:rollbar#pyramid
access_token = POST_SERVER_ITEM_ACCESS_TOKEN
environment = production
branch = master
root = %(here)s

Note that the access_token, environment, and other Rollbar config params do need to be present in both the app section and the filter section.

Additionally, note that because Pyramid uses INI files for configuration, any changes to nested settings, like the locals dictionary, will need to be handled in code.

Flask

Please make sure to install Flask and blinker dependencies first.

pip install Flask
pip install blinker

Check out the Flask examples or rollbar-flask-example.

FastAPI

There are several options for installing Rollbar in FastAPI applications.

The following examples use the async handler that requires the HTTPX package to be installed. It's okay if you don't want to use/install it. In this case, a default sync handler is used.

You may also want to install the python-multipart package that is required for parsing request body content (this is the FastAPI requirement).

Run the examples (saved as a main.py file) via ASGI server (e.g. Uvicorn, Hypercorn or Daphne):

uvicorn main:app

Be sure to replace POST_SERVER_ITEM_ACCESS_TOKEN with your project's post_server_item access token, which you can find in the Rollbar.com interface.

Check out FastAPI examples in our GitHub repository.

Integrate via FastAPI Router

Integration via the router allows to send payload with more data (e.g. a request body content).
This is recommended option for reporting uncaught errors. It requires FastAPI version 0.41.0 or later.

import fastapi
import rollbar
from rollbar.contrib.fastapi import add_to as rollbar_add_to

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
  'POST_SERVER_ITEM_ACCESS_TOKEN',
  environment='production',
  handler='async',
  include_request_body=True
)

# Integrate Rollbar with FastAPI application before adding routes to the app
app = fastapi.FastAPI()
rollbar_add_to(app)

# Alternatively, you can integrate with any APIRouter
# router = fastapi.APIRouter()
# rollbar_add_to(router)

# Add an /error endpoint to cause an uncaught exception
async def localfunc(arg1, arg2, arg3):
    # Both local variables and function arguments will be sent to Rollbar
    # and available in the UI
    localvar = 'local variable'
    cause_error_with_local_variables

@app.get('/error')
async def read_error():
    await localfunc('func_arg1', 'func_arg2', 1)
    return {'result': "You shouldn't be seeing this")

NOTE: By default, this integration allows to report some user errors (e.g. RequestValidationError or HTTPException). You can ignore the reporting any errors by using payload handler feature.

Integrate via middleware

It is also possible to report errors via middleware. This integration should work with all versions of FastAPI.
Please note that FastAPI doesn't allow middleware to collect a streaming content like a request body.

import fastapi
import rollbar
from rollbar.contrib.fastapi import ReporterMiddleware as RollbarMiddleware

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
  'POST_SERVER_ITEM_ACCESS_TOKEN',
  environment='production',
  handler='async',
)

# Integrate Rollbar with FastAPI application
app = fastapi.FastAPI()
app.add_middleware(RollbarMiddleware)  # should be added as the first middleware

# Add an /error endpoint to cause an uncaught exception
async def localfunc(arg1, arg2, arg3):
    # Both local variables and function arguments will be sent to Rollbar
    # and available in the UI
    localvar = 'local variable'
    cause_error_with_local_variables

@app.get('/error')
async def read_error():
    await localfunc('func_arg1', 'func_arg2', 1)
    return {'result': "You shouldn't be seeing this")

Integrate with logging handler

FastAPI LOGGING handler reports log entries. For example errors that happen outside of the router/middleware, such as in Celery job queue tasks that run in the background separate from web requests.
Note that using LoggerMiddleware is optional, however it allows adding a request object to the payload. If you would like to use it in Python 3.6, you must to install the aiocontextvars package. For later versions of Python (3.7+), this package is not necessary.

import logging

import fastapi
import rollbar

from rollbar.contrib.fastapi import LoggerMiddleware
from rollbar.logger import RollbarHandler

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
    'ACCESS_TOKEN',
    environment='staging',
    handler='async',
)

# Set root logger to log DEBUG and above
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Report ERROR and above to Rollbar
rollbar_handler = RollbarHandler()
rollbar_handler.setLevel(logging.ERROR)

# Attach Rollbar handler to the root logger
logger.addHandler(rollbar_handler)

# Integrate Rollbar with FastAPI application to add request objects to the payload
app = fastapi.FastAPI()
app.add_middleware(LoggerMiddleware)  # should be added as the last middleware

# Add an endpoint
@app.get('/')
async def read_root():
    # Report log entries
    logger.critical('Critical message sent to Rollbar')
    logger.error('Error message sent to Rollbar')

    # Ignore log entries
    logger.warning('Warning message is not sent to Rollbar')
    logger.info('Info message is not sent to Rollbar')
    logger.debug('Debug message is not sent to Rollbar')

    return {'hello': 'world'}

Global access for FastAPI request objects

FastAPI doesn't provide global access for request objects. However, if you are using any of the Rollbar integrations described above, you can access it via rollbar.get_request().

The example below shows integration via LoggerMiddleware without reporting errors to Rollbar. This is minimal integration to have an access to request objects. Remember that you don't need to add LoggerMiddleware to your application if you already have integration enabled for catching errors by using other options described above.

If you would like to use this feature in Python 3.6, you must to install the aiocontextvars package. For later versions of Python (3.7+), this package is not necessary.

import fastapi
import rollbar
from rollbar.contrib.fastapi import LoggerMiddleware

# Integrate Rollbar with FastAPI application
app = fastapi.FastAPI()
app.add_middleware(LoggerMiddleware)  # should be added as the last middleware

async def get_user_agent():
    # Global access to the current request object
    request = rollbar.get_request()

    user_agent = request.headers['User-Agent']
    return user_agent

@app.get('/')
async def read_root():
    user_agent = await get_user_agent()
    return {'user-agent': user_agent}

Report a message

If you would like to report a message to Rollbar, you can use the function rollbar.report_message() or delegate awaitable task to your event loop:

import fastapi
import rollbar
from rollbar.lib._async import report_message

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
    'ACCESS_TOKEN',
    environment='staging',
)

app = fastapi.FastAPI()

@app.get('/)
async def read_root():
    await report_message('This is a message')
    return {'hello': 'world'}

This feature requires the HTTPX package to be installed.

Starlette

There are several options for installing Rollbar in Starlette applications.

The following examples use the async handler that requires the HTTPX package to be installed. It's okay if you don't want to use/install it. In this case, a default sync handler is used.

You may also want to install the python-multipart package that is required for parsing request body content (this is the Starlette requirement).

Run the examples (saved as a main.py file) via ASGI server (e.g. Uvicorn, Hypercorn or Daphne):

uvicorn main:app

Be sure to replace POST_SERVER_ITEM_ACCESS_TOKEN with your project's post_server_item access token, which you can find in the Rollbar.com interface.

Check out Starlette examples in our GitHub repository.

Integrate via middleware

import rollbar
from rollbar.contrib.starlette import ReporterMiddleware as RollbarMiddleware
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
    'ACCESS_TOKEN',
    environment='staging',
    handler='async',
)

# Integrate Rollbar with Starlette application
app = Starlette()
app.add_middleware(RollbarMiddleware)  # should be added as the first middleware

# Add an /error endpoint to cause an uncaught exception
async def localfunc(arg1, arg2, arg3):
    # Both local variables and function arguments will be sent to Rollbar
    # and available in the UI
    localvar = 'local variable'
    cause_error_with_local_variables

@app.route('/error')
async def error(request):
    await localfunc('func_arg1', 'func_arg2', 1)
    return PlainTextResponse("You shouldn't be seeing this")

Please note that Starlette doesn't allow middleware to collect a streaming content like a request body.

Integrate with logging handler

Starlette LOGGING handler reports log entries. For example errors that happen outside of the router/middleware, such as in Celery job queue tasks that run in the background separate from web requests.
Note that using LoggerMiddleware is optional, however it allows adding a request object to the payload. If you would like to use it in Python 3.6, you must to install the aiocontextvars package. For later versions of Python (3.7+), this package is not necessary.

import logging

import rollbar

from rollbar.contrib.starlette import LoggerMiddleware
from rollbar.logger import RollbarHandler
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
    'ACCESS_TOKEN',
    environment='staging',
    handler='async',
)

# Set root logger to log DEBUG and above
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# Report ERROR and above to Rollbar
rollbar_handler = RollbarHandler()
rollbar_handler.setLevel(logging.ERROR)

# Attach Rollbar handler to the root logger
logger.addHandler(rollbar_handler)

# Integrate Rollbar with Starlette application to add request objects to the payload
app = Starlette()
app.add_middleware(LoggerMiddleware)  # should be added as the last middleware

# Add an endpoint
@app.route('/')
async def root(request):
    # Report log entries
    logger.critical('Critical message sent to Rollbar')
    logger.error('Error message sent to Rollbar')

    # Ignore log entries
    logger.warning('Warning message is not sent to Rollbar')
    logger.info('Info message is not sent to Rollbar')
    logger.debug('Debug message is not sent to Rollbar')

    return PlainTextResponse('hello world')

Global access for Starlette request objects

Starlette doesn't provide global access for request objects. However, if you are using any of the Rollbar integrations described above, you can access it via rollbar.get_request().

The example below shows integration via LoggerMiddleware without reporting errors to Rollbar. This is minimal integration to have an access to request objects. Remember that you don't need to add LoggerMiddleware to your application if you already have integration enabled for catching errors by using other options described above.

If you would like to use this feature in Python 3.6, you must to install the aiocontextvars package. For later versions of Python (3.7+), this package is not necessary.

import rollbar
from rollbar.contrib.starlette import LoggerMiddleware
from starlette.applications import Starlette
from starlette.responses import JSONResponse

# Integrate Rollbar with Starlette application
app = Starlette()
app.add_middleware(LoggerMiddleware)  # should be added as the last middleware

async def get_user_agent():
    # Global access to the current request object
    request = rollbar.get_request()

    user_agent = request.headers['User-Agent']
    return user_agent

@app.route('/')
async def root(request):
    user_agent = await get_user_agent()
    return JSONResponse({'user-agent': user_agent})

Report a message

If you would like to report a message to Rollbar, you can use the function rollbar.report_message() or delegate awaitable task to your event loop:

import rollbar
from rollbar.lib._async import report_message
from starlette.applications import Starlette
from starlette.responses import PlainTextResponse

# Initialize Rollbar SDK with your server-side access token
rollbar.init(
    'ACCESS_TOKEN',
    environment='staging',
)

app = Starlette()

@app.route('/')
async def root(request):
    await report_message('This is a message')
    return PlainTextResponse('hello world')

This feature requires the HTTPX package to be installed.

Bottle

Import the plugin and install!
Can be installed globally or on a per route basis.

import bottle
from rollbar.contrib.bottle import RollbarBottleReporter

rbr = RollbarBottleReporter(access_token='POST_SERVER_ITEM_ACCESS_TOKEN', environment='production') #setup rollbar

bottle.install(rbr) #install globally

@bottle.get('/')
def raise_error():
  '''
  When navigating to /, we'll get a regular 500 page from bottle,
  as well as have the error below listed on Rollbar.
  '''
  raise Exception('Hello, Rollbar!')

if __name__ == '__main__':
    bottle.run(host='localhost', port=8080)

Be sure to replace POST_SERVER_ITEM_ACCESS_TOKEN with your project's post_server_item access token, which you can find in the Rollbar.com interface.

Twisted

Please make sure to install twisted and treq first.

pip install twisted
pip install treq

Check out the Twisted example.

AWS Lambda

The biggest issue with the Lambda execution environment is that as soon as you return from your handler function, any work executing in other threads will stop executing as the process is frozen. This is true also of any child processes that one may spawn. Furthermore, the Lambda environment implements multithreading via a hypervisor on a single CPU core. Therefore, using separate threads to do additional work will not necessarily lead to better performance.

In order to ensure that the Rollbar library works correctly, meaning that items are transmitted to the Rollbar API, one must not return from the main handler function before all of this work completes. In order to ensure this, one can either use the blocking handler by specifying this value in the configuration,

rollbar.init(token, environment='production', handler='blocking')

or use the Rollbar function wait to delay the return from your function until all Rollbar threads have finished. Note that we use threads for the handler if otherwise unspecified, therefore you must use wait if you do not set the handler.

wait is a function which takes an optional function as an argument. It waits for all currently running Rollbar created threads to stop processing, meaning it waits for any items to be sent over the network, then it returns the result of calling the function passed as an argument or None if no function was given. Hence, one can use it via

def lambda_handler(event, context):
    try:
        result = ...
        return rollbar.wait(lambda: result)
    except:
        rollbar.report_exc_info()
        rollbar.wait()
        raise

We provide a decorator for your handler functions which takes care of calling wait properly as well as catching any exceptions, namely rollbar.lambda_function:

import os
import rollbar

token = os.getenv('ROLLBAR_KEY', 'missing_api_key')
rollbar.init(token, 'production')

@rollbar.lambda_function
def lambda_handler(event, context):
    return some_other_function('Hello from Lambda')

Other

For generic Python or a non-Django/non-Pyramid framework just initialize the Rollbar library with your access token and environment.

rollbar.init('POST_SERVER_ITEM_ACCESS_TOKEN', environment='production', **other_config_params)

Other options can be passed as keyword arguments. See the reference below for all options.

Command-line usage

pyrollbar comes with a command-line tool that can be used with other UNIX utilities to create an ad-hoc monitoring solution.

e.g. Report all 5xx haproxy requests as warning

tail -f /var/log/haproxy.log | awk '{print $11,$0}' | grep '^5' | awk '{$1="";print "warning",$0}' | rollbar -t POST_SERVER_ITEM_ACCESS_TOKEN -e production -v

e.g. Test an access token

rollbar -t POST_SERVER_ITEM_ACCESS_TOKEN -e test debug testing access token

Reference

$ rollbar --help
Usage: rollbar [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -t ACCESS_TOKEN, --access_token=ACCESS_TOKEN
                        You project's access token from rollbar.com.
  -e ENVIRONMENT, --environment=ENVIRONMENT
                        The environment to report errors and messages to.
  -u ENDPOINT_URL, --url=ENDPOINT_URL
                        The Rollbar API endpoint url to send data to.
  -m HANDLER, --handler=HANDLER
                        The method in which to report errors.
  -v, --verbose         Print verbose output.

Usage

The Django, Pyramid, Flask, and Bottle integrations will automatically report uncaught exceptions to Rollbar.

Exceptions

To report a caught exception to Rollbar, use rollbar.report_exc_info():

try:
    do_something()
except:
    rollbar.report_exc_info(sys.exc_info())
    # or if you have a webob-like request object, pass that as well:
    # rollbar.report_exc_info(sys.exc_info(), request)

Logging

You can also send any other log messages you want, using rollbar.report_message():

try:
    do_something()
except IOError:
    rollbar.report_message('Got an IOError while trying to do_something()', 'warning')
    # report_message() also accepts a request object:
    #rollbar.report_message('message here', 'warning', request)

Ignoring items

To ignore an item and not send to Rollbar, add a payload handler. The payload handler will be called for each payload, and your custom logic can be applied to determine whether to send or ignore. To send, return the payload object. To ignore, return False.

Note: Payload handlers must be added after Rollbar.init(), as init() will reset the list of handlers.

Example:

import rollbar
 
rollbar.init(ACCESS_TOKEN, 'production')
 
def ignore_handler(payload, **kw): # kw is currently unused
   if payload['data']['environment'] == 'test':
       return False
   else:
       return payload
 
rollbar.events.add_payload_handler(ignore_handler)

Transforming the payload

To add, remove or modify data in the payload before sending, add a payload handler. The payload handler will be called for each payload, and any part of the payload can be modified before returning. Any changes to the payload must comply with the Rollbar API schema, or the payload will be rejected at the API.

Note: Payload handlers must be added after Rollbar.init(), as init() will reset the list of handlers.

Example:

import rollbar
 
rollbar.init(ACCESS_TOKEN, 'production')
 
def payload_handler(payload, **kw): # kw is currently unused
   payload['data']['foo'] = 'bar' # Add new key/value to the payload
   return payload
 
rollbar.events.add_payload_handler(payload_handler)

Examples

Here's a full example, integrating into a simple Gevent app.

"""
Sample Gevent application with Rollbar integration.
"""
import sys
import logging

from gevent.pywsgi import WSGIServer
import rollbar
import webob

# configure logging so that rollbar's log messages will appear
logging.basicConfig()

def application(environ, start_response):
    request = webob.Request(environ)
    status = '200 OK'
    headers = [('Content-Type', 'text/html')]
    start_response(status, headers)

    yield '<p>Hello world</p>'

    # extra fields we'd like to send along to rollbar (optional)
    extra_data = {'datacenter': 'us1', 'app' : {'version': '1.1'}}

    try:
        # will raise a NameError about 'bar' not being defined
        foo = bar
    except:
        # report full exception info
        rollbar.report_exc_info(sys.exc_info(), request, extra_data=extra_data)

        # and/or, just send a string message with a level
        rollbar.report_message("Here's a message", 'info', request, extra_data=extra_data)

        yield '<p>Caught an exception</p>'

# initialize rollbar with an access token and environment name
rollbar.init('POST_SERVER_ITEM_ACCESS_TOKEN', 'development')

# now start the wsgi server
WSGIServer(('', 8000), application).serve_forever()

Configuration reference

Option

Description

access_token

Access token from your Rollbar project

agent.log_file

If handler is agent, the path to the log file. Filename must end in .rollbar

branch

Name of the checked-out branch.

Default: master

code_version

A string describing the current code revision/version (i.e. a git sha). Max 40 characters.

Default: None

enabled

Controls whether or not Rollbar will report any data

Default: True

endpoint

URL items are posted to.

Default: https://api.rollbar.com/api/1/item/

environment

Environment name. Any string up to 255 chars is OK. For best results, use production for your production environment.

exception_level_filters

List of tuples in the form (class, level) where class is an Exception class you want to always filter to the respective level. Any subclasses of the given class will also be matched.

Valid levels: 'critical', 'error', 'warning', 'info', 'debug' and 'ignored'.

Use 'ignored' if you want an Exception (sub)class to never be reported to Rollbar.

Any exceptions not found in this configuration setting will default to 'error'.

Django settings.py example (and Django default):

from django.http import Http404

ROLLBAR = {
    ...
    'exception_level_filters': [
        (Http404, 'warning')
    ]
}

In a Pyramid ini file, define each tuple as an individual whitespace delimited line, for example:

rollbar.exception_level_filters =
    pyramid.exceptions.ConfigurationError critical
    #...

handler

The method for reporting rollbar items to api.rollbar.com

One of:

  • default -- uses default handler (thread for sync reporting and async for async reporting)
  • blocking -- runs in main thread
  • thread -- spawns a new thread
  • async -- uses default (httpx) async handler to send the payload
  • agent -- writes messages to a log file for consumption by rollbar-agent
  • httpx -- uses the HTTPX async library to send the payload
  • tornado -- uses the Tornado async library to send the payload
  • gae -- uses the Google AppEngineFetch library to send the payload
  • twisted -- uses the Twisted event-driven networking library to send the payload

Default: default

locals

Configuration for collecting local variables. A dictionary:

  • enabled
    • If True, variable values will be collected for stack traces. Default True.
  • safe_repr
    • If True, non-built-in objects will be serialized into just their class name. If False repr(obj) will be used for serialization. Default True.
  • sizes
    • Dictionary of configuration describing the max size to repr() for each type.
      • maxdict: Default 10
      • maxarray: Default 10
      • maxlist: Default 10
      • maxtuple: Default 10
      • maxset: Default 10
      • maxfrozenset: Default 10
      • maxdeque: Default 10
      • maxstring: Default 100
      • maxlong: Default 40
      • maxother: Default 100
  • whitelisted_types
    • A list of type objects, (e.g. type(my_class_instance) or MyClass) that will be serialized using
      repr(). Default []
  • scrub_varargs
    • If True, variable argument values will be scrubbed. Default True.

root

Absolute path to the root of your application, not including the final /.

scrub_fields

List of sensitive field names to scrub out of request params and locals. Values will be replaced with asterisks. If overriding, make sure to list all fields you want to scrub, not just fields you want to add to the default. Param names are converted to lowercase before comparing against the scrub list.

Default: ['pw', 'passwd', 'password', 'secret', 'confirm_password', 'confirmPassword', 'password_confirmation', 'passwordConfirmation', 'access_token', 'accessToken', 'auth', 'authentication']

timeout

Timeout for any HTTP requests made to the Rollbar API (in seconds).

Default: 3

allow_logging_basic_config

When True, logging.basicConfig() will be called to set up the logging system. Set to False to skip this call. If using Flask, you'll want to set to False. If using Pyramid or Django, True should be fine.

Default: True

url_fields

List of fields treated as URLs and scrubbed.

Default ['url', 'link', 'href']

verify_https

If True, network requests will fail unless encountering a valid certificate. Default True.

shortener_keys

A list of key prefixes (as tuple) to apply our shortener transform to. Added to built-in list:

[
    ('body', 'request', 'POST'),
    ('body', 'request', 'json')
]

If locals.enabled is True, extra keys are also automatically added:

[
    ('body', 'trace', 'frames', '*', 'code'),
    ('body', 'trace', 'frames', '*', 'args', '*'),
    ('body', 'trace', 'frames', '*', 'kwargs', '*'),
    ('body', 'trace', 'frames', '*', 'locals', '*')
]

Default: []

suppress_reinit_warning

If True, suppresses the warning normally shown when rollbar.init() is called multiple times.

Default: False.

capture_ip

If equal to True, we will attempt to capture the full client IP address from a request.

If equal to the string anonymize, we will capture the client IP address, but then semi-anonymize it by masking out the least significant bits.

If equal to False, we will not capture the client IP address from a request.

Default: True

capture_email

If set to True, we will attempt to enrich person data with an email address if available.

Default: False

capture_username

If set to True, we will attempt to enrich person data with a username if available.

Default: False

Help / Support

If you run into any issues, please email us at [email protected]

For bug reports, please open an issue on GitHub.

Updated 3 months ago


Python


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.