Loading...
Loading...
Full Sentry SDK setup for Ruby. Use when asked to add Sentry to Ruby, install sentry-ruby, setup Sentry in Rails/Sinatra/Rack, or configure error monitoring, tracing, logging, metrics, profiling, or crons for Ruby applications. Also handles migration from AppSignal or Honeybadger. Supports Rails, Sinatra, Rack, Sidekiq, and Resque.
npx skill4agent add getsentry/sentry-agent-skills sentry-ruby-sdksentry-rubysentry-railsNote: SDK APIs below reflect sentry-ruby v6.4.0. Always verify against docs.sentry.io/platforms/ruby/ before implementing.
# Existing Sentry gems
grep -i sentry Gemfile 2>/dev/null
# Framework
grep -E '"rails"|"sinatra"' Gemfile 2>/dev/null
# Background jobs
grep -E '"sidekiq"|"resque"|"delayed_job"' Gemfile 2>/dev/null
# Competitor monitoring tools — triggers migration path if found
grep -E '"appsignal"|"honeybadger"' Gemfile 2>/dev/null
# Existing metric patterns (StatsD, Datadog, Prometheus)
grep -rE "(statsd|dogstatsd|prometheus|\.gauge|\.histogram|\.increment|\.timing)" \
app/ lib/ --include="*.rb" 2>/dev/null | grep -v "_spec\|_test" | head -20
# Companion frontend
cat package.json frontend/package.json web/package.json 2>/dev/null | grep -E '"@sentry|"sentry-'appsignalhoneybadgerreferences/migration.mdconfig/initializers/honeybadger.rbconfig/initializers/appsignal.rbsentry-railsconfig/initializers/sentry.rbsentry-rubySentry::Rack::CaptureExceptionssentry-sidekiq| Feature | Recommend when... |
|---|---|
| Error Monitoring | Always |
| Tracing | Rails / Sinatra / Rack / any HTTP framework |
| Logging | Always — |
| Metrics | Sidekiq present; existing metric lib (StatsD, Prometheus) detected |
| Profiling | ⚠️ Beta — performance profiling requested; requires |
| Crons | Scheduled jobs detected (ActiveJob, Sidekiq-Cron, Clockwork, Whenever) |
# Gemfile
gem "sentry-ruby"
gem "sentry-rails"
gem "sentry-sidekiq" # if using Sidekiq
gem "sentry-resque" # if using Resque
gem "sentry-delayed_job" # if using DelayedJobgem "sentry-ruby"bundle installconfig/initializers/sentry.rbSentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.spotlight = Rails.env.development? # local Spotlight UI; no DSN needed in dev
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
config.send_default_pii = true
config.traces_sample_rate = 1.0 # lower to 0.05–0.2 in production
config.enable_logs = true
# Metrics on by default; disable with: config.enable_metrics = false
endsentry-railsrequire "sentry-ruby"
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.spotlight = ENV["RACK_ENV"] == "development"
config.breadcrumbs_logger = [:sentry_logger, :http_logger]
config.send_default_pii = true
config.traces_sample_rate = 1.0
config.enable_logs = true
end
use Sentry::Rack::CaptureExceptions # in config.ru, before app middlewarerequire "sentry-ruby"
require "sentry-sidekiq"
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.spotlight = ENV.fetch("RAILS_ENV", "development") == "development"
config.breadcrumbs_logger = [:sentry_logger]
config.traces_sample_rate = 1.0
config.enable_logs = true
endSENTRY_DSN=https://xxx@oYYY.ingest.sentry.io/ZZZ
SENTRY_ENVIRONMENT=production # overrides RAILS_ENV / RACK_ENV
SENTRY_RELEASE=my-app@1.0.0| Feature | Reference | Load when... |
|---|---|---|
| Migration | | Competitor gem found — load before installing Sentry |
| Error Monitoring | | Always |
| Tracing | | HTTP handlers / distributed tracing |
| Logging | | Structured log capture |
| Metrics | | Sidekiq present; existing metric patterns |
| Profiling | | Performance profiling requested (beta) |
| Crons | | Scheduled jobs detected or requested |
Sentry.init| Option | Type | Default | Purpose |
|---|---|---|---|
| String | | SDK disabled if empty; env: |
| String | | e.g., |
| String | | e.g., |
| Boolean | | Send events to Spotlight sidecar (local dev, no DSN needed) |
| Boolean | | Include IP addresses and request headers |
| Float | | Error event sample rate (0.0–1.0) |
| Float | | Transaction sample rate; |
| Float | | Profiling rate relative to |
| Boolean | | Enable Sentry structured Logs |
| Boolean | | Enable custom metrics (on by default) |
| Array | | Loggers for automatic breadcrumbs (see logging reference) |
| Integer | | Max breadcrumbs per event |
| Boolean | | Verbose SDK output to stdout |
| Lambda | | Mutate or drop error events before sending |
| Lambda | | Mutate or drop transaction events before sending |
| Lambda | | Mutate or drop log events before sending |
| Variable | Maps to | Purpose |
|---|---|---|
| | Data Source Name |
| | App version (e.g., |
| | Deployment environment |
Sentry.initnpx @spotlightjs/spotlight # browser UI at http://localhost:8969
# or stream events to terminal:
npx @spotlightjs/spotlight tail traces --format jsonconfig.spotlight = Rails.env.development?Sentry.capture_message("Sentry Ruby SDK test")config.debug = truehttps://<key>@o<org>.ingest.sentry.io/<project>cat package.json frontend/package.json web/package.json 2>/dev/null | grep -E '"@sentry|"sentry-'| Frontend detected | Suggest |
|---|---|
| React / Next.js | |
| Svelte / SvelteKit | |
| Vue | |
references/tracing.md| Issue | Solution |
|---|---|
| Events not appearing | |
| Rails exceptions missing | Must use |
| No traces | Set |
| Sidekiq jobs not traced | Add |
| Missing request context | Set |
| Logs not appearing | Set |
| Metrics not appearing | Check |