Skip to content

Commit

Permalink
fix to configure exception notifier without changing interfering with…
Browse files Browse the repository at this point in the history
… middleware
  • Loading branch information
stuzart committed Jan 9, 2025
1 parent 4b7e766 commit 685448b
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions lib/seek/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,33 @@ def configure_recaptcha_keys

def configure_exception_notification
if exception_notification_enabled && Rails.env.production?
SEEK::Application.config.middleware.use ExceptionNotification::Rack,
ignore_exceptions: ['ActionDispatch::Http::Parameters::ParseError',
'ActionController::InvalidAuthenticityToken',
'ActionController::UnknownHttpMethod',
'ActionController::BadRequest'] + ExceptionNotifier.ignored_exceptions,
email: {
sender_address: [noreply_sender],
email_prefix: "[ #{instance_name} ERROR ] ",
exception_recipients: exception_notification_recipients.nil? ? [] : exception_notification_recipients.split(/[, ]/)
},
error_grouping: error_grouping_enabled,
error_grouping_period: error_grouping_timeout,
notification_trigger: ->(exception, count) {
# Send notifications at count = x^0, x^1, x^3, x^4... where
# x = error_grouping_log_base
(Math.log(count,error_grouping_log_base) % 1).zero?
}
ExceptionNotification.configure do |config|
config.register_exception_notifier :email, {
ignore_exceptions: ['ActionDispatch::Http::Parameters::ParseError',
'ActionController::InvalidAuthenticityToken',
'ActionController::UnknownHttpMethod',
'ActionController::BadRequest'] + ExceptionNotifier.ignored_exceptions,
email: {
sender_address: [noreply_sender],
email_prefix: "[ #{instance_name} ERROR ] ",
exception_recipients: exception_notification_recipients.nil? ? [] : exception_notification_recipients.split(/[, ]/)
},
error_grouping: error_grouping_enabled,
error_grouping_period: error_grouping_timeout,
notification_trigger: ->(exception, count) {
# Send notifications at count = x^0, x^1, x^3, x^4... where
# x = error_grouping_log_base
(Math.log(count, error_grouping_log_base) % 1).zero?
}
}
end
else
SEEK::Application.config.middleware.delete ExceptionNotifier
ExceptionNotification.configure do |config|
config.unregister_exception_notifier :email
end
end
rescue RuntimeError => e
Rails.logger.warn('Cannot update middleware with exception notification changes, server needs restarting')
Rails.logger.warn('Cannot update exception notification changes, server needs restarting')
end

def solr_enabled_propagate
Expand Down

0 comments on commit 685448b

Please sign in to comment.