Configuration
You can set configuration options for the Honeybadger client by calling the
honeybadger.configure method. This can be called in one of your application
files such as settings.py or wsgi.py, or in a custom middleware.
from honeybadger import honeybadger
honeybadger.configure( api_key="PROJECT_API_KEY", environment="production", project_root="/path/to/your/project/root", excluded_exceptions=["SomeIgnoredException"],)See Configuration Options for a list of available options.
Twelve-factor configuration
Section titled “Twelve-factor configuration”Most of Honeybadger’s configuration options can also be set via environment
variables with the HONEYBADGER_ prefix
(12-factor style). For example, the api_key option can
be set via the HONEYBADGER_API_KEY environment variable:
export HONEYBADGER_API_KEY="PROJECT_API_KEY"export HONEYBADGER_ENVIRONMENT="production"Filtering and enriching errors
Section titled “Filtering and enriching errors”The before_notify handler allows you to filter or modify error notifications
before they’re sent to Honeybadger:
def custom_before_notify(notice): # Skip notifications for specific error types if notice.error_class == 'MyCustomError': return False # Skip this notification
# Add custom context notice.context['custom_data'] = 'example'
# Return the notice to send it return notice
honeybadger.configure(before_notify=custom_before_notify)Return False from the handler to skip the notification. Return the notice
object to send it.
Filtering and enriching events
Section titled “Filtering and enriching events”The before_event handler allows you to filter or modify performance events
before they’re sent to Honeybadger:
def custom_before_event(event): # Skip events from health check endpoints if event.get('path') == '/health': return False # Skip this event
# Add custom metadata for slow requests if event.get('duration', 0) > 1000: # Over 1 second event['slow_request'] = True
# Return the event to send it return event
honeybadger.configure(before_event=custom_before_event)Return False from the handler to skip the event. Return the event object to
send it.
Configuration options
Section titled “Configuration options”The following options are available to you:
| Name | Type | Default |
|---|---|---|
api_key | str | "" |
project_root | str | The current working directory |
environment1 | str | "production" |
development_environments | list | ['development', 'dev', 'test'] |
hostname | str | The hostname of the current server. |
endpoint | str | "https://api.honeybadger.io" |
params_filters | list | ['password', 'password_confirmation', 'credit_card', 'CSRF_COOKIE'] |
force_report_data | bool | False |
excluded_exceptions | list | [] |
force_sync | bool | False |
report_local_variables | bool | False |
insights_enabled | bool | False |
insights_config | dict | {} (see Insights Configuration) |
events_sample_rate | int | 100 (0-100, percentage of events to send) |
events_batch_size | int | 1000 |
events_max_queue_size | int | 10000 |
events_timeout | float | 5.0 |
events_max_batch_retries | int | 3 |
events_throttle_wait | float | 60.0 |
before_notify | callable | lambda notice: notice |
before_event | callable | lambda event: event |
Insights configuration
Section titled “Insights configuration”The insights_config option accepts a dictionary with configuration for
Honeybadger’s automatic instrumentation:
from honeybadger import honeybadger
honeybadger.configure( insights_enabled=True, insights_config={ "django": {"include_params": True}, "db": {"disabled": True}, "celery": {"exclude_tasks": ["cleanup_task"]} })Each instrumented framework has its own set of options:
| Framework | Name | Type | Default | Description |
|---|---|---|---|---|
| django | ||||
disabled | bool | False | Disable Django instrumentation | |
include_params | bool | False | Include GET/POST parameters in request events | |
| flask | ||||
disabled | bool | False | Disable Flask instrumentation | |
include_params | bool | False | Include GET/POST parameters in request events | |
| asgi | ||||
disabled | bool | False | Disable ASGI instrumentation | |
include_params | bool | False | Include query parameters in request events | |
| celery | ||||
disabled | bool | False | Disable Celery instrumentation | |
include_args | bool | False | Include task arguments/kwargs in events | |
exclude_tasks | list[str or regex] | [] | List of task names or regex patterns to exclude | |
| db | ||||
disabled | bool | False | Disable database instrumentation | |
include_params | bool | False | Include SQL parameters in query events | |
exclude_queries | list[str or regex] | System queries2 | List of queries to exclude |
Footnotes
Section titled “Footnotes”-
Honeybadger will try to infer the correct environment when possible. For example, in the case of the Django integration, if Django settings are set to
DEBUG = True, the environment will default todevelopment. ↩ -
Default excluded queries include Django migrations, auth tables, and common system queries. Import
default_excluded_queriesfromhoneybadger.configto see the full list. ↩