Install bugstack for Ruby
Railtie for Rails, Sinatra extension, and generic at_exit integration. Zero runtime dependencies.
Compatibility
Ruby 3.0+
Install
Gemfile
gem "bugstack"
Then run:
bundle install
Or install directly:
gem install bugstack
Initialize
Initialize with your API key and use begin/rescue to capture errors:
require "bugstack"
Bugstack.init(api_key: ENV["BUGSTACK_API_KEY"])
begin
risky_operation
rescue => e
Bugstack.capture_exception(e)
end
Or use the block configuration style:
Bugstack.init do |config|
config.api_key = ENV["BUGSTACK_API_KEY"]
config.environment = "production"
end
Rails
Add bugstack to your Gemfile:
# Gemfile
gem "bugstack"
Create an initializer at config/initializers/bugstack.rb:
# config/initializers/bugstack.rb
Bugstack.init do |config|
config.api_key = ENV["BUGSTACK_API_KEY"]
config.environment = Rails.env
end
The gem ships with a Railtie that automatically inserts the error-capture middleware. No additional configuration is required.
Sinatra
require "sinatra"
require "bugstack"
Bugstack.init(api_key: ENV["BUGSTACK_API_KEY"])
register Bugstack::Integrations::Sinatra
get "/" do
"Hello World"
end
Generic Ruby
For scripts, workers, or any Ruby process, install the at_exit hook:
require "bugstack"
Bugstack.init(api_key: ENV["BUGSTACK_API_KEY"])
# Captures unhandled exceptions on process exit
Bugstack::Integrations::Generic.install!
Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
String | — | Required. Your bugstack API key. |
environment |
String | "production" |
Environment name (production, staging, etc.). |
auto_fix |
Boolean | true |
Enable automatic fix generation via GitHub PRs. |
debug |
Boolean | false |
Log internal SDK activity to STDERR. |
dry_run |
Boolean | false |
Process errors locally without sending to the API. |
enabled |
Boolean | true |
Master kill switch for error capture. |
deduplication_window |
Integer | 60 |
Window in seconds to deduplicate identical errors. |
timeout |
Integer | 5 |
HTTP timeout in seconds for sending reports. |
max_retries |
Integer | 3 |
Number of retries on failed HTTP requests. |
ignored_errors |
Array | [] |
Exception classes to ignore (e.g., [SignalException]). |
before_send |
Proc | nil |
Hook to transform or drop payloads before sending. |
Data Control
before_send hook example
Drop health-check errors from being reported:
Bugstack.init do |config|
config.api_key = ENV["BUGSTACK_API_KEY"]
config.before_send = ->(payload) {
return nil if payload[:request_path] == "/health"
payload
}
end
dry_run mode
Test your integration without sending data to the API:
Bugstack.init do |config|
config.api_key = ENV["BUGSTACK_API_KEY"]
config.dry_run = true
config.debug = true # logs payloads to STDERR
end
Next Steps
Start capturing Ruby errors now
bugstack catches runtime errors in production, writes the fix, runs your CI, and opens a tested pull request — in under 2 minutes.