There’s an ExceptionNotifier plugin wich makes errors caused in controller action sent to you by email. The problem is that the site sometimes can face an issue that makes it error on nearly each request. The emails make it quickly noticed and fixed appropriately, but if the site have some load there will be significant number of these error emails which is annoying (or often harmful) considering that you have a limit on SMTP server.

So in my company we wanted to make error email notifications sent by ExceptionNotifier and the likes not sent immediately but combined into digest email each minute. We used adzap-ar_mailer for error messages buffering and then made it combine them to digests based on To field. Also we already had BackgrounDRB so we didn’t need separate ar_sendmail process.

Adzap’s fork is great because you can use ar_mailer for just one class with it – just what we needed. So we decided to opensource our tweaks in hope that it will be helpful for someone, and put our changes to a fork on GitHub: artemv/ar_mailer. The code is quite limited but it’s fine for our needs, and if you need more you have smth to start with. E.g. it could be improved to support text/html messages or to make certain classes bypass digesting when sending emails with ARMailer.

So, what does this fork do out of the box:

  • ARMailer messages don’t get send until they are combined into digests
  • all messages to same addressee are combined into one digest email
  • digesting only supports text/plain messages
  • if the digest mail is too big it gets truncated, and full digest is dumped to a file on server; truncated digest will tell about it
  • the sending itself can be triggered by method call, so now you have options to use ar_sendmail process or smth else, e.g. BackgrounDRB job
  • you can specify :smtp_settings to be used when sending digests: we needed it to be other than default ActionMailer::Base.smtp_settings

Usage example:

ActionMailer::ARSendmail.digest_error_emails(
    :dump_path => '/var/log/myapp',
    :subj_prefix => ExceptionNotifier.email_prefix,
    :smtp_settings =>   {:address =>     "localhost",
        :port =>        25,
        :domain =>      'my_domain.com',
        :tls =>          false}
)

The fork is contributed by Your Net Works, Inc.

Links:



5 Responses to “error emails digesting: ar_mailer fork”  

  1. 1 Kosta

    Sorry for terrible offtopic but why there’s no feed with blog entries?

    Cheers,
    Kosta from Lux

    • 2 thirstydoh

      Hi amigo Kosta!

      No feed? My FF shows me RSS link in address bar, looks like it works: http://thirstydoh.wordpress.com/feed/

      Maybe you’re drunk today, that’s understood! )

      • 3 Kosta

        Good for your FF, Artem!) But I don’t use FF anymore. And to be honest in my firefox times I rarely used that feed button in address bar.) I like these big red feed burner buttons placed directly on page, you know. That’s my little fetish :)

    • 4 thirstydoh

      you what? oh well. wonder what you use now? chrome? I tried it but I hate tabs and it doesn’t have delicious bookmarks, so I switched back to good ol’ FF.

      • 5 Kosta

        “I hate tabs that’s why I use firefox”. Nice motto)


Leave a Reply