newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class. * Log all exceptions to New Relic, not just statement timeouts.
This commit is contained in:
@@ -230,9 +230,7 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
|
||||
yield
|
||||
rescue ::ActiveRecord::StatementInvalid => x
|
||||
if Rails.env.production?
|
||||
NewRelic::Agent.notice_error(x, :custom_params => new_relic_params.merge(:user_id => CurrentUser.id, :user_ip_addr => CurrentUser.ip_addr))
|
||||
end
|
||||
DanbooruLogger.log(x, expected: true)
|
||||
return default_value
|
||||
ensure
|
||||
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"
|
||||
|
||||
Reference in New Issue
Block a user