Skip to content

Traces for successful Rails actions with a redirect are ignored by default #3093

Description

@jaytennier

Issue Description

In a typical Rails CRUD app any create, update, or destroy action will issue a 302 redirect after successfully completing the action but none of the traces/spans created during those actions will get reported because the 302 status code is ignored by default in the trace_ignore_status_codes configuration option.

Reproduction Steps

  1. Enable Sentry SDK debugging:
  config.sdk_logger = Sentry::Logger.new(STDOUT)
  config.sdk_logger.level = ::Logger::DEBUG
  1. Issue a redirect from any Rails action (I hope I don't need to provide a working Rails app for this):
class UsersController
  def create
    @user = User.new(user_params)

    if @user.save
      redirect_to users_path
    else
      render :new
    end
  end
end
  1. Invoke the Rails action in your app
  2. Observe a log entry that looks like the following: DEBUG -- sentry: ** [Sentry] [Tracing] Discarding <http.server> transaction </users> due to ignored HTTP status code: 302
  3. Observe that no traces for the action are available in Sentry

This can be fixed by including the following line in the Sentry.init block:

config.trace_ignore_status_codes = [301, 303, (305..399), (401..404)]

Expected Behavior

I would expect that by default Sentry's Rails integration would record traces for all of the typical CRUD actions when using standard Rails idioms - e.g. redirect on success. And if for some reason that's not possible, I'd at least expect to see a huge alert or warning or something in the Rails integration docs that mentions that by default you won't get traces for any Rails action that succeeds with a redirect unless you change the configuration.

Actual Behavior

No traces get recorded for any successful create, update, or destroy action when redirecting the user to subsequent page.

Ruby Version

ruby 4.0.3 (2026-04-21 revision 85ddef263a) +PRISM [arm64-darwin24]

SDK Version

6.7.0

Integration and Its Version

sentry-rails (6.7.0)

Sentry Config

Sentry.init do |config|
  config.dsn = SentryConfig.new.dsn
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]

  # Set the environment to the name of the app instance instead of the Rails/Rack
  # env value because all of the DigitalOcean apps will be running as "production" apps
  # (even staging).
  config.environment = AppConfig.new.name

  # Add data like request headers and IP for users,
  # see https://docs.sentry.io/platforms/ruby/data-management/data-collected/ for more info
  config.send_default_pii = true

  # Enable sending logs to Sentry
  config.enable_logs = true
  # Patch Ruby logger to forward logs
  config.enabled_patches = [:logger]

  # Set traces_sample_rate to 1.0 to capture 100%
  # of transactions for tracing.
  # We recommend adjusting this value in production.
  config.traces_sample_rate = 1.0
  # or
  # config.traces_sampler = lambda do |context|
  #   true
  # end
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions