Let's say you have a .NET system that needs to send out email notifications to a system administrator when there's an error. Example:
try
{
//do something mission critical
}
catch(Exception ex)
{
//send ex to the system administrator
//give the customer a user-friendly explanation
}
This block of code gets called hundreds of times a second by different users.
Now lets's say an underlying API/service/database goes down. This code is going to fail many, many times. The poor administrator is going to wake up to a few million e-mails in their inbox and the developer is going to get a rude phone call, not that such an incident (cough) necessarily occurred this morning.
It's pretty clear that this is not a design that scales well.
The first few solutions that come to mind are all flawed in some way:
This seems like a problem that has to have been solved, and that we're going about it in a silly way. Suggestions appreciated, even if they involve a completely different exception management strategy!
Disable Notifications in Chrome If you want to turn off these messages completely, select Don't allow sites to send notifications. This will stop all push notifications from your browser, but this will also include productivity-related notifications from apps like Gmail and Google Meet.
the simplest solution that springs to mind is to assign this exception block an ID number (like, 1) and log the time of the last notification to the administrator. If the elapsed time between notifications is not large enough (say, an hour), don't notify the admin again
if this piece of code typically generates more than one kind of exception, you may want to log the class of the exception also; if the elapsed time between notifications for the same exception is not large enough, don't notify the admin again
Check for similarities (timestamps can be evaded using wildcards (??:?? for example)) and first let them be sent to you for a period of time. Now check which occured the most.
Say, there are 1000 exceptions of type A, 964 of type B, 120 of C and 7 of Types D - H.
That means, send an email to the sysadmin every 100th exception of type A and B, every 10th of Type C and every other excpetion as it occurs.
Pro:
+ Accurate
+ Prevents System-Spam
+ Not much code to implement
Con:
- Needs time to develop a reliable statistic
- Important Exceptions could be ignored accidently
- Relies on humans, which will probably always fail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With