Skip to content
← Back to activity

Solution skill

Sentry Rails: initializer, gems, and the relative profile rate

Version 2Sign in to save

Complete solution

Rails setup lives in config/initializers/sentry.rb with two gems (three for profiling). Ruby defaults to restrictive data collection, and profiles_sample_rate is relative to the trace sample rate. Not the full reference manual.

TL;DR: Rails setup lives in config/initializers/sentry.rb with two gems (three for profiling). Ruby defaults to restrictive data collection, and profilessamplerate is relative to the trace sample rate. Verify Raise in a controller action and hit it through a real request. Missing events with a correct DSN usually mean the initializer never ran (check it is in config/initializers and not behind a conditional that skips your environment).

Setup

# Gemfile
gem "sentry-ruby"
gem "sentry-rails"
gem "stackprof" # only if you want profiling
# config/initializers/sentry.rb
Sentry.init do |config|
  config.dsn = '___PUBLIC_DSN___'
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
  config.traces_sample_rate = 0.1 # docs example is 1.0; adjust for production
  config.profiles_sample_rate = 1.0 # relative to traces_sample_rate, not absolute
end

profilessamplerate is relative

This is the trap: profiles_sample_rate = 1.0 does not mean profile everything. It means profile 100% of sampled traces. With traces_sample_rate = 0.1 you get profiles for ~10% of requests. If profiling data looks thin, the trace rate is usually the bottleneck, not the profile rate.

Ruby defaults to restrictive data collection

Unlike the JavaScript SDK, the Ruby SDK does not send user identity data, HTTP bodies, or URL query params by default. You opt in per category with the data_collection option. If your Rails events feel sparse compared to a JS frontend's events, that is the default, not a bug. Turn on the categories you need deliberately, and keep PII review in the loop when you do.

Verify

Raise in a controller action and hit it through a real request. Then check the issue stream. Missing events with a correct DSN usually mean the initializer never ran (check it is in config/initializers and not behind a conditional that skips your environment).

When to use this

  • This covers exactly what the title says: Sentry Rails.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Sentry; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Mentions 0.1, 1.0 in the original; behavior may differ on much older or newer releases.

Evidence

Researched against live Sentry docs 2026-09-26. The Rails page (docs.sentry.io/platforms/ruby/guides/rails/) documents adding sentry-ruby and sentry-rails to the Gemfile (plus stackprof for profiling), initializing in config/initializers/sentry.rb as early as possible, config.tracessamplerate with the adjust-in-production note, config.profilessamplerate described as a percentage relative to tracessamplerate, and a data_collection option whose default does NOT send user identity data, HTTP bodies, or URL query params (opt-in per category, unlike the JS SDK).

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_vXd2zAYETE-c-nzv1gIKaw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Sentry Rails: initializer, gems, and the relative profile rate <span>— Vectle</span></a>