From 300bc6941edc7fd911a2fe47a3601c5e38beb969 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 14 Oct 2021 23:39:21 -0500 Subject: [PATCH] newrelic: log with_timeout errors as expected. Make it so that when a database call inside a `with_timeout` block times out, the error logged to New Relic is marked as expected. This is so that expected timeouts, such as timeouts when calculating search counts or timeouts when generating related tags for the sidebar, don't count against the error rate. --- app/models/application_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index d598a00e5..dc0296360 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -136,7 +136,7 @@ class ApplicationRecord < ActiveRecord::Base connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env.test? yield rescue ::ActiveRecord::StatementInvalid => e - DanbooruLogger.log(e, expected: false, **new_relic_params) + DanbooruLogger.log(e, expected: true, **new_relic_params) default_value ensure connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env.test?