Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting error notification emails 1

Status
Not open for further replies.

LarrySteele

Programmer
May 18, 2004
318
US
Working on one of those high visibility intranet sites where any errors causes a lot of noise.

I have a proof-of-concept page that catches errors and sends an email via cfmail. Works great....

However, if 100 people hit the site while it's down, I really don't need 100 emails. I just need the first email.

What I think I'd like is for the page to see when the last error email was sent. If less than 15 minutes, don't send again. If more than 15, then do send since it may be a new error.

The part that I haven't been able to figure out is how the page would be able to know when the last email was sent. Barring that, maybe when the last error occurred. I don't want to store errors in a database, because I'm trapping for database errors. If the database itself goes down, then I'm back to receiving more emails than necessary.

So finally to my question... Any suggestions on how I might limit the number of emails when we have errors?

Thanks in advance for any ideas.

 
Depending on the context, you have access to shared scopes like application, etecetera. So in theory you could store tracking information in a persistent scope.

What I think I'd like is for the page to see when the last error email was sent. If less than 15 minutes, don't send again. If more than 15, then do send since it may be a new error.

But you might want implement more granular handling. If you are basing it solely off of timestamps, you could miss notifications if multiple (unrelated) errors occurred around the same time.

----------------------------------
 
Hm. Just did a little research and think I see what you mean. I've used session variables, but not application variables.

From what I've seen, seems like I could create an application variable (e.g. application.lastError) where I could store the timestamp when an error occurs. Since it's an application variable, all sessions have access to this variable - do I understand scope correctly?

Looks like I have something to work with in the morning. It's just minutes before midnight, so the banner in your blog is spot on!
 
Bonzer!

I'm not sure if I've ever worked with application variables, so don't have experience to rely on. For some reason, my variables weren't getting set. After several hits on Google, I stumbled upon this nugget: "Application variables work only if an application name is defined." Once I gave it a name, my variables appeared just like I wanted them to.

It'll take a bit to implement, but this will certainly make error reporting a lot easier on everyone.

Thanks again for the assist!
 
Application variables work only if an application name is defined

Yep. Though I always thought it a bit odd you are even allowed to omit the application name. Maybe there is some use case for it I am not aware of ? ;)

It probably does not matter in this case, but keep in mind that modifying shared variables from multiple threads introduces the possibility of race conditions. So in some situations you would want to use locking, usually a granular named lock. But it all depends on the application.





----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top