health monitoring
TRANSCRIPT
![Page 1: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/1.jpg)
ASP.NET Health Monitoring
Milan Negovan
![Page 3: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/3.jpg)
![Page 4: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/4.jpg)
![Page 5: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/5.jpg)
9 times of out 10
there’s nothing you can do
![Page 6: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/6.jpg)
But…
You must know about it
![Page 7: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/7.jpg)
Exception handling “greatest hits”
![Page 8: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/8.jpg)
Why I think “trying again” is a bad idea.
![Page 9: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/9.jpg)
catch (Exception ex)
{
string txt = ex.Message;
}
Exhibit A: a meaningless assignment
![Page 10: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/10.jpg)
catch (Exception XXX)
{
string txt = XXX.Message;
}
Exhibit B: an adult version of the same
![Page 11: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/11.jpg)
catch (Exception ex)
{
return false;
}
Exhibit C: a “magic” return value
![Page 12: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/12.jpg)
catch (Exception ex)
{
res = -1;
}
Exhibit D: C++ blues
![Page 13: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/13.jpg)
catch (Exception ex)
{
}
Exhibit E: horrible exception swallowing
![Page 14: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/14.jpg)
catch { }
Exhibit F: same
![Page 15: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/15.jpg)
catch (Exception Ex)
{
int i;
i=0;
}
Exhibit G: spinning one’s wheels
![Page 16: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/16.jpg)
catch (Exception ex)
{
throw ex;
}
Exhibit H: you gain what again?
![Page 17: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/17.jpg)
public static bool SendEmail (
string To,
string From,
string Subject,
string Body,
bool HtmlFormatted,
out Exception error)
{
//...
}
Exhibit I: catch me if you can
![Page 18: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/18.jpg)
Why so averse to exceptions?
![Page 19: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/19.jpg)
Set up a custom error page
<customErrorsdefaultRedirect="~/errors/GenericError.aspx" mode="RemoteOnly" />
![Page 20: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/20.jpg)
Save yourself embarrassment
![Page 21: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/21.jpg)
So what is Health Monitoring about?
![Page 22: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/22.jpg)
![Page 23: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/23.jpg)
The “what”
What do you want to be notified about?
![Page 24: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/24.jpg)
![Page 25: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/25.jpg)
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.
![Page 26: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/26.jpg)
DemoCustom events
![Page 27: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/27.jpg)
The “how”
How do you want them delivered?
![Page 28: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/28.jpg)
ASP.NET 2.0 ships with the following providers:
• Windows Event Log• SQL Server• E-mail• WMI• Diagnostics Tracing
![Page 29: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/29.jpg)
![Page 30: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/30.jpg)
Custom providersLook it up ;)
![Page 31: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/31.jpg)
![Page 32: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/32.jpg)
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>
![Page 33: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/33.jpg)
BufferingLook it up ;)
![Page 34: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/34.jpg)
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>
![Page 35: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/35.jpg)
DemoA simple exception thrown and written to the system event log.
![Page 36: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/36.jpg)
TipRemember to deploy with debug symbols.
![Page 37: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/37.jpg)
Health Monitoring as a convenient way to keep track of whose fault it is.
![Page 38: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/38.jpg)
Questions
![Page 39: Health Monitoring](https://reader033.vdocument.in/reader033/viewer/2022042819/55cee525bb61ebba108b462a/html5/thumbnails/39.jpg)
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