health monitoring
TRANSCRIPT
ASP.NET Health Monitoring
Milan Negovan
MILANNEGOVANROASTS ASP.NET WITH WEB STANDARDS
ASP.NET CONSULTING SERVICEShttp://[email protected]
9 times of out 10
there’s nothing you can do
But…
You must know about it
Exception handling “greatest hits”
Why I think “trying again” is a bad idea.
catch (Exception ex)
{
string txt = ex.Message;
}
Exhibit A: a meaningless assignment
catch (Exception XXX)
{
string txt = XXX.Message;
}
Exhibit B: an adult version of the same
catch (Exception ex)
{
return false;
}
Exhibit C: a “magic” return value
catch (Exception ex)
{
res = -1;
}
Exhibit D: C++ blues
catch (Exception ex)
{
}
Exhibit E: horrible exception swallowing
catch { }
Exhibit F: same
catch (Exception Ex)
{
int i;
i=0;
}
Exhibit G: spinning one’s wheels
catch (Exception ex)
{
throw ex;
}
Exhibit H: you gain what again?
public static bool SendEmail (
string To,
string From,
string Subject,
string Body,
bool HtmlFormatted,
out Exception error)
{
//...
}
Exhibit I: catch me if you can
Why so averse to exceptions?
Set up a custom error page
<customErrorsdefaultRedirect="~/errors/GenericError.aspx" mode="RemoteOnly" />
Save yourself embarrassment
So what is Health Monitoring about?
The “what”
What do you want to be notified about?
Preconfigured event mappings:
•All events. Anything and everything that happens on your site.
•Application Lifetime Events. Application compilation, start-up and shutdown.
•All Errors. Any and all errors on the site.
•Infrastructure Errors. Compilation, configuration, parse, etc, errors.
•Request Processing Errors. View state and validation errors, as well as all unhandled exceptions.
DemoCustom events
The “how”
How do you want them delivered?
ASP.NET 2.0 ships with the following providers:
• Windows Event Log• SQL Server• E-mail• WMI• Diagnostics Tracing
Custom providersLook it up ;)
Profiles: default and critical<profiles>
<add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" />
<add name="Critical" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
</profiles>
BufferingLook it up ;)
By default all errors are logged in the system event log
<rules><add
name="All Errors Default" eventName="All Errors" provider="EventLogProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" />
…</rules>
DemoA simple exception thrown and written to the system event log.
TipRemember to deploy with debug symbols.
Health Monitoring as a convenient way to keep track of whose fault it is.
Questions
Goodies Keeping Pulse on Your Site With ASP.NET 2.0
Health Monitoring
Why So Averse To Exceptions?
How To: Instrument ASP.NET 2.0 Applications for Security
How to: Send E-mail for Health Monitoring Notifications
Raising Custom ASP.NET Health Monitoring Events Example