Error reporting to Sentry through Rails.error.report

I’ve added sentry-rails (6.2.0) and sentry-ruby (6.2.0).

I’ve configured with config/initializers/sentry.rb this way:

Sentry.init do |config|
  config.dsn = "REDACTED"
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]

  config.excluded_exceptions -= ['ActionController::RoutingError', 'ActiveRecord::RecordNotFound', 'AbstractController::ActionNotFound']
  config.trace_ignore_status_codes = [(301..303), (305..399)]

  config.send_default_pii = true
end

I’ve tested this integration and received some events on the Sentry Dashboard. However I’m struggling to get two things:

  1. Reports of HTTP 4** errors.
  2. Getting Rails.error.report(e) to report exceptions to Sentry.

Based on this documentation: Error Reporting in Rails Applications — Ruby on Rails Guides

I assume that calling Rails.error.report(e) should report exceptions to Sentry.

Does anyone have an experience with Sentry and its integration with Rails?

Am I mis-interpreting the Rails guides regarding use of Rails.error?

Is it possible to get HTTP 400 errors reported to Sentry?

I’ll offer that the thing I would do is read the docs about the Rails Error reporter and the subscriber interface. Then I’d go read the Sentry-Rails gem source on GitHub and see if it implements the subscriber interface.

For 404s, I’m fairly certain Sentry has an ignore list. The first one that comes to mind is ActiveRecord::NotFound. If you search the gem source on GitHub, you might find the ignore list and docs.

Thanks for the suggestion. I found this nugget in the sentry-rails code:

If you want Sentry to subscribe to the error reporter, please set `config.rails.register_error_subscriber` to `true`.

That seems to have fixed the main issue. I’ll dig deeper on the 400s. I’m getting 404s with the ActionController::RoutingError setting. I’d also like to have visibility to 400, 406, and 422. I’ll dig deeper.

Thanks. I appreciate your help. It got me unblocked.