Reputation: 1473
My Rails 4 app on Heroku (currently on unicorn) doesn't have too many errors usually but it gets tons of bad URLs. Whenever a bad URL is entered, the user sees my 404 page and an ActionController::RoutingError is raised in Rails. This gets reported to Rollbar and NewRelic as errors, and they raise the alarms. I'm constantly getting alerts from NewRelic about all these "errors". How do I prevent a routing error from being reported as an error?
(I tried changing a line in newrelic.yml to ignore_errors: ActionController::RoutingError
but it didn't help.)
Upvotes: 2
Views: 1858
Reputation: 25142
Even though Rollbar
recommends handling ActionController::RoutingError
via a match '*unmatched'
route, this still won't get rid of the internal Rails warning that ends up in Rollbar.
To suppress the warning you can add this to your Rollbar config:
/config/rollbar.rb
Rollbar.configure do |config|
# ...
config.exception_level_filters['ActionController::RoutingError'] = 'ignore'
end
Another option is to add a middleware to constrain requests before Rails handles them.
Upvotes: 0
Reputation: 1708
Since the other answer takes care of New Relic, the solution in Rollbar is to add the following line into config/initializers/rollbar.rb (see comments in that file for more info):
config.exception_level_filters.merge!('ActionController::RoutingError' => 'ignore')
Upvotes: 8
Reputation: 351
If you're using Server Side Config (determine this on the app's Settings page in New Relic), be sure that ActionController::RoutingError
is included in the Ignore these errors
field.
You might also try setting an environment variable on Heroku to ignore errors like this. For example, NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERRORS="ActiveRecord::RecordNotFound, ActionController::RoutingError"
Upvotes: 1