SDK · Ruby
Ruby
Official Bugwatch SDK for Ruby 3.x. Zero external dependencies. Events are sent on background threads, so a slow or down Bugwatch server never stalls your application. A Rack middleware captures every uncaught exception with full request context.
Install
Shell
gem install bugwatch-sdkQuickstart
Ruby
require "bugwatch"
Bugwatch.init("https://bw-YOUR_KEY@bugwatch-api.loadmindx.com/api/1",
environment: "production",
release: "1.0.0"
)
begin
risky_operation
rescue StandardError => e
Bugwatch.capture_exception(e)
end
Bugwatch.capture_message("Payment confirmed", "info")
Bugwatch.flush # wait for async sends (short-lived scripts)Rails / Sinatra (Rack middleware)
Ruby
# config.ru — capture every uncaught exception with request context
require "bugwatch"
use Bugwatch::RackMiddleware,
dsn: "https://bw-YOUR_KEY@bugwatch-api.loadmindx.com/api/1",
environment: "production"
run MyAppThe middleware rescues every exception, attaches the request method, path and headers (auth cookies stripped), reports it, then re-raises so your error pages keep working.
API
| API | Description |
|---|---|
| init(dsn, **opts) | Parse the DSN, validate HTTPS (unless allow_http). Options: environment, release, sample_rate, debug, allow_http. |
| capture_exception(exc, level: "error") -> id? | Capture a Ruby exception with backtrace and culprit. |
| capture_message(msg, level) -> id? | Capture a message: debug, info, warning, error or fatal. |
| set_tag(k, v) | Set a tag on subsequent events. |
| set_user(id, **extra) | Set user context (PII stripped). |
| add_breadcrumb(category:, message:) | Append to the trail (max 100). |
| clear_scope | Clear tags, user and breadcrumbs. |
| flush | Join pending sender threads. Call it before the process exits. |
