mcpField
S
sentry-ruby-setup

sentry-ruby-setup

github.com/getsentryDevelopment25104 installsUpdated 35w ago
Repository

About sentry-ruby-setup

sentry-ruby-setup is a setup skill for adding Sentry to Ruby projects, for developers who need error monitoring, logging, or tracing. It covers standard Ruby and Rails configuration, with verification and troubleshooting guidance.

Key features

  1. 01Install sentry-ruby
  2. 02Configure Sentry initialization
  3. 03Integrate Rails and background-job components
  4. 04Set up log breadcrumbs, tracing, and profiling
  5. 05Verify event capture and troubleshoot issues

Use cases

  1. 01Add error monitoring to a Ruby app
  2. 02Configure Sentry in a Rails project
  3. 03Enable tracing or profiling for requests
  4. 04Diagnose missing error or trace reports

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/getsentry/sentry-agent-skills --skill sentry-ruby-setup

After installing, type/sentry-ruby-setupin Claude Code to confirm it loaded.

Details

From the project README

Sentry Ruby Setup

Install and configure Sentry in Ruby projects.

Invoke This Skill When

  • User asks to "add Sentry to Ruby" or "install Sentry" in a Ruby app
  • User wants error monitoring, logging, or tracing in Ruby
  • User mentions "sentry-ruby" gem or Ruby on Rails

Important: The configuration options and code samples below are examples. Always verify against docs.sentry.io before implementing, as APIs and defaults may have changed.

Requirements

  • Ruby 2.4+ or recent JRuby versions

Install

Add to Gemfile:

gem "sentry-ruby"

# For profiling, add ONE of:
gem "stackprof"  # SDK 5.9.0+ — works on all Ruby versions
# gem "vernier"  # SDK 5.21.0+ — requires Ruby 3.2.1+, better for multi-threaded servers
                 # Also requires: config.profiler_class = Sentry::Vernier::Profiler

Then run:

bundle install

Configure

Initialize as early as possible:

require "sentry-ruby"

Sentry.init do |config|
  config.dsn = "YOUR_SENTRY_DSN"
  config.send_default_pii = true
  
  # Breadcrumbs from logs
  config.breadcrumbs_logger = [:sentry_logger, :http_logger]
  
  # Tracing
  config.traces_sample_rate = 1.0
  
  # Profiling (requires stackprof or vernier gem)
  config.profiles_sample_rate = 1.0
  # config.profiler_class = Sentry::Vernier::Profiler  # Uncomment if using vernier
  
  # Logs
  config.enable_logs = true
end

Rails Integration

For Rails, add to config/initializers/sentry.rb:

Sentry.init do |config|
  config.dsn = ENV["SENTRY_DSN"]
  config.send_default_pii = true
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  config.traces_sample_rate = 1.0
  config.profiles_sample_rate = 1.0
  config.enable_logs = true
end
Rails-specific Gems
# Gemfile
gem "sentry-ruby"
gem "sentry-rails"  # Rails integration
gem "sentry-sidekiq"  # If using Sidekiq
gem "sentry-delayed_job"  # If using Delayed Job
gem "sentry-resque"  # If using Resque

Configuration Options

OptionDescriptionDefault
dsnSentry DSNnil (SDK no-ops without it)
send_default_piiInclude user datafalse
traces_sample_rate% of transactions tracednil (tracing disabled)
profiles_sample_rate% of traces profilednil (profiling disabled)
enable_logsSend logs to Sentryfalse
environmentEnvironment name"development" (checks SENTRY_CURRENT_ENV, SENTRY_ENVIRONMENT, RAILS_ENV, RACK_ENV in order)
releaseRelease versionAuto-detected

Breadcrumb Loggers

LoggerDescription
:sentry_loggerSentry's own logger
:http_loggerHTTP request breadcrumbs
:redis_loggerRedis command breadcrumbs
:active_support_loggerRails ActiveSupport (Rails only)

Environment Variables

SENTRY_DSN=https://[email protected]/456
SENTRY_AUTH_TOKEN=sntrys_xxx
SENTRY_ORG=my-org
SENTRY_PROJECT=my-project

Verification

# Capture test message
Sentry.capture_message("Test message from Ruby")

# Or trigger intentional error
1 / 0

Troubleshooting

IssueSolution
Errors not appearingEnsure Sentry.init called early, check DSN
No tracesSet traces_sample_rate > 0
No profilesAdd stackprof gem, set profiles_sample_rate
Rails errors missingUse sentry-rails gem instead of sentry-ruby

Comments

Markdown supported