Honeybadger Python

1.2.2 · active · verified Fri Apr 17

Honeybadger Python is the official client library for sending Python and Django errors to Honeybadger.io. It provides real-time error tracking, uptime monitoring, and performance insights for applications built with frameworks like Django, Flask, and Celery, as well as general Python applications and AWS Lambda functions. The library is actively maintained, with version 1.2.2 being the latest, and receives frequent updates including bug fixes and minor features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic initialization using an API key (preferably from an environment variable) and how to manually send an exception to Honeybadger. For immediate reporting in short-lived scripts, `force_sync=True` is recommended. Remember to replace `HONEYBADGER_API_KEY` with your actual API key from your Honeybadger project settings.

import honeybadger
import os

# Configure Honeybadger using an environment variable or direct assignment
honeybadger.configure(api_key=os.environ.get('HONEYBADGER_API_KEY', ''))

def problematic_function():
    raise ValueError("This is a test error from Honeybadger Python!")

try:
    problematic_function()
except Exception as e:
    # Manually send the error to Honeybadger
    honeybadger.notify(e, force_sync=True)
    print("Error notified to Honeybadger. Check your dashboard.")

# Example of setting custom context
honeybadger.set_context(user_id=123, email='test@example.com')

view raw JSON →