diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f534309d..1b924993c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - Include otel as custom sampling context ([2683](https://github.com/getsentry/sentry-ruby/pull/2683)) +- Ignore new rails rate limit errors ([#2774](https://github.com/getsentry/sentry-ruby/pull/2774)) ## 6.1.2 diff --git a/sentry-rails/lib/sentry/rails/configuration.rb b/sentry-rails/lib/sentry/rails/configuration.rb index 42306e07f..a37c4446c 100644 --- a/sentry-rails/lib/sentry/rails/configuration.rb +++ b/sentry-rails/lib/sentry/rails/configuration.rb @@ -15,6 +15,7 @@ class Configuration after(:initialize) do @rails = Sentry::Rails::Configuration.new @excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::IGNORE_DEFAULT) + @excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::RAILS_8_1_1_IGNORE_DEFAULT) if Gem::Version.new(::Rails.version) >= Gem::Version.new("8.1.1") if ::Rails.logger if defined?(::ActiveSupport::BroadcastLogger) && ::Rails.logger.is_a?(::ActiveSupport::BroadcastLogger) @@ -50,12 +51,18 @@ module Rails "ActionController::RoutingError", "ActionController::UnknownAction", "ActionController::UnknownFormat", - "ActionDispatch::Http::MimeNegotiation::InvalidType", "ActionController::UnknownHttpMethod", + "ActionDispatch::Http::MimeNegotiation::InvalidType", "ActionDispatch::Http::Parameters::ParseError", "ActiveRecord::RecordNotFound" ].freeze + # Rails 8.1.1 introduced ActionController::TooManyRequests for rate limiting + # https://github.com/rails/rails/commit/73ecd0ced634e5177496677a2986ec3731c7e2ee + RAILS_8_1_1_IGNORE_DEFAULT = [ + "ActionController::TooManyRequests" + ].freeze + ACTIVE_SUPPORT_LOGGER_SUBSCRIPTION_ITEMS_DEFAULT = { # action_controller "write_fragment.action_controller" => %i[key], diff --git a/sentry-rails/spec/sentry/rails/configuration_spec.rb b/sentry-rails/spec/sentry/rails/configuration_spec.rb index 58b38353c..7c64a12cd 100644 --- a/sentry-rails/spec/sentry/rails/configuration_spec.rb +++ b/sentry-rails/spec/sentry/rails/configuration_spec.rb @@ -15,6 +15,12 @@ expect(config.excluded_exceptions).to include("ActiveRecord::RecordNotFound") end + it "ignores ActionController::TooManyRequests by default on Rails 8.1.1+", skip: Gem::Version.new(Rails.version) < Gem::Version.new("8.1.1") do + config = Sentry::Configuration.new + + expect(config.excluded_exceptions).to include("ActionController::TooManyRequests") + end + describe "#report_rescued_exceptions" do it "has correct default value" do expect(subject.report_rescued_exceptions).to eq(true)