Configuration
Complete configuration reference for ActiveRabbit.
ActiveRabbit can be configured through an initializer file. All configuration options are optional except for the API key.
Basic Configuration
# config/initializers/activerabbit.rb
ActiveRabbit.configure do |config|
# Required: Your API key from the dashboard
config.api_key = ENV['ACTIVERABBIT_API_KEY']
# Optional: Application name (defaults to Rails.application.class.module_parent_name)
config.app_name = 'MyApp'
# Optional: Environment (defaults to Rails.env)
config.environment = Rails.env
# Optional: Release/version tracking
config.release = ENV['GIT_SHA'] || `git rev-parse HEAD`.strip
endConfiguration Options
Core Settings
| Option | Type | Default | Description |
|---|---|---|---|
api_key | String | nil | Your ActiveRabbit API key (required) |
app_name | String | Rails app name | Name displayed in the dashboard |
environment | String | Rails.env | Environment name (production, staging, etc.) |
release | String | nil | Release version or git SHA |
enabled | Boolean | true | Enable/disable error reporting |
Data Filtering
ActiveRabbit.configure do |config|
# Filter sensitive parameters (merged with Rails defaults)
config.filter_parameters = [
:password,
:password_confirmation,
:credit_card,
:cvv,
:ssn,
/secret/i,
/token/i,
/api_key/i
]
# Filter specific headers
config.filter_headers = [
'Authorization',
'Cookie',
'X-Api-Key'
]
# Filter environment variables
config.filter_env = [
/KEY/i,
/SECRET/i,
/PASSWORD/i
]
endError Sampling
ActiveRabbit.configure do |config|
# Sample rate (0.0 to 1.0)
# 1.0 = capture 100% of errors
# 0.5 = capture 50% of errors
config.sample_rate = 1.0
# Maximum errors per minute (rate limiting)
config.max_errors_per_minute = 100
# Ignore specific exception classes
config.ignored_exceptions = [
ActiveRecord::RecordNotFound,
ActionController::RoutingError,
ActionController::InvalidAuthenticityToken
]
# Ignore errors matching patterns
config.ignore_if do |event|
event.exception.message.include?('bot')
end
endContext & Metadata
ActiveRabbit.configure do |config|
# Add custom tags to all events
config.tags = {
server: `hostname`.strip,
cluster: ENV['CLUSTER_NAME']
}
# Add user context automatically
config.before_send do |event|
if defined?(Current) && Current.user
event.user = {
id: Current.user.id,
email: Current.user.email,
name: Current.user.name
}
end
event
end
# Add extra context
config.extra = {
custom_field: 'value'
}
endPerformance Monitoring
ActiveRabbit.configure do |config|
# Enable performance monitoring
config.performance_monitoring = true
# Track transactions (controller actions)
config.track_transactions = true
# Slow query threshold in milliseconds
config.slow_query_threshold = 100
# Detect N+1 queries
config.detect_n_plus_one = true
# Track memory allocations
config.track_allocations = true
# Sample rate for performance data (independent of error sampling)
config.performance_sample_rate = 0.25
endTransport Settings
ActiveRabbit.configure do |config|
# API endpoint (for self-hosted installations)
config.endpoint = 'https://api.activerabbit.ai'
# Request timeout in seconds
config.timeout = 5
# Enable async sending (recommended)
config.async = true
# Background worker threads
config.worker_threads = 2
# Queue size for async sending
config.queue_size = 1000
endEnvironment-Specific Configuration
# config/initializers/activerabbit.rb
ActiveRabbit.configure do |config|
config.api_key = ENV['ACTIVERABBIT_API_KEY']
case Rails.env
when 'production'
config.sample_rate = 1.0
config.performance_sample_rate = 0.1
when 'staging'
config.sample_rate = 1.0
config.performance_sample_rate = 0.5
when 'development'
# Disable in development by default
config.enabled = ENV['ACTIVERABBIT_DEV'] == 'true'
config.sample_rate = 1.0
when 'test'
config.enabled = false
end
endCallbacks & Hooks
ActiveRabbit.configure do |config|
# Modify events before sending
config.before_send do |event|
# Add custom data
event.extra[:deployment_id] = ENV['DEPLOYMENT_ID']
# Drop events conditionally (return nil)
return nil if event.user&.dig(:email)&.end_with?('@test.com')
# Return modified event
event
end
# Callback after event is sent
config.after_send do |event, response|
Rails.logger.info "Sent error to ActiveRabbit: #{event.id}"
end
# Handle send failures
config.on_error do |error, event|
Rails.logger.error "Failed to send to ActiveRabbit: #{error.message}"
end
end📝 Configuration Tips
- Always use environment variables for sensitive values like API keys
- Start with
sample_rate = 1.0and reduce if you hit rate limits - Test your
before_sendcallbacks thoroughly in staging