Server SDK

Error monitoring for Ruby

One gem for Rails, Rack, and Sinatra. On Rails it wires itself in through a railtie; on plain Rack you add one middleware line.

Frameworks Rails · Rack · SinatraRequires Ruby 3.0+Package errorgapSource ↗Package ↗Agent guide ↗
Install

Install

sh
bundle add errorgap
Configure

Configure

Rails

Create config/initializers/errorgap.rb:

ruby
Errorgap.configure do |config|
  config.endpoint     = ENV.fetch("ERRORGAP_ENDPOINT")
  config.project_slug = ENV.fetch("ERRORGAP_PROJECT_SLUG")
  config.api_key      = ENV.fetch("ERRORGAP_API_KEY")
end

The gem installs Rack middleware automatically and reports unhandled exceptions from every environment. To skip reporting in some environments, set config.ignore_environments = %w[test development].

Rack / Sinatra

In your boot file (config.ru or app.rb), configure the SDK and add the middleware before the app runs:

ruby
require "errorgap"

Errorgap.configure do |config|
  config.endpoint     = ENV.fetch("ERRORGAP_ENDPOINT")
  config.project_slug = ENV.fetch("ERRORGAP_PROJECT_SLUG")
  config.api_key      = ENV.fetch("ERRORGAP_API_KEY")
end

use Errorgap::RackMiddleware
Keep the key in an environment variable (or your framework's secret store) — never commit it to source control.
Trigger a test error

Trigger a test error

From rails console, a throwaway route, or a controller action:

ruby
raise "Errorgap test error"

Exceptions in a request cycle are reported automatically; from a console, use Errorgap.notify(StandardError.new("Errorgap test error")).

Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.