Let's say you have a .NET system that should send email notifications to the system administrator when an error occurs. Example:
try {
This block of code is called hundreds of times per second by different users.
Now let's say that the base API / service / database is omitted. This code will fail many, many times. The poor administrator is about to wake up to several million emails in his inbox, and the developer is about to receive a rude phone call, and not that such an incident (cough) necessarily happened this morning.
It's pretty clear that this is not a design that scales well.
The first few decisions that come to mind are all spoiled:
- The error log in the database, and then output a high error count through an HTTP health check to an external monitoring service such as Pingdom . (My favorite candidate is still. But what if the database goes down?)
- Have a static cache that tracks the latest exceptions, and the warning system always checks for duplicates. (It seems unnecessarily complicated, and secondly, many error messages differ very little - for example, if there is a time stamp in the error, this is useless.)
- Programmatically disable our system after certain errors or based on constant monitoring of critical dependencies (risky! What if there is a transient false positive?)
- Just do not report these errors and rely on another part of the system to track and report dependencies. (Does not cater for "unexpected" errors that we did not expect.)
This is like a problem that needs to be solved, and that we are doing it is stupid. Suggestions are evaluated even if they are associated with a completely different exception management strategy!
realworldcoder
source share