Skip to content

Instantly share code, notes, and snippets.

@jlxw
Created August 15, 2012 08:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jlxw/3357795 to your computer and use it in GitHub Desktop.
Save jlxw/3357795 to your computer and use it in GitHub Desktop.
Monkey patch to rate limit Rails Exception Notification / Notifier
ExceptionNotifier::Notifier.class_eval do
#https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier/notifier.rb
def self.exception_notification(*args)
message = super
_limit = 5.minutes.ago
@@last_notification||=_limit
if @@last_notification > _limit
Rails.logger.info "ExceptionNotifier rate limit triggered, #{ExceptionNotifier::Notifier.deliveries.size} notifications limited."
message.delivery_method :test
else
@@last_notification = Time.now
end
message
end
end
@ruslansavenok
Copy link

You can do same logic in config.ignore_if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment