Health Monitoring

39
ASP.NET Health Monitoring Milan Negovan

Transcript of Health Monitoring

Page 1: Health Monitoring

ASP.NET Health Monitoring

Milan Negovan

Page 2: Health Monitoring

MILANNEGOVANROASTS ASP.NET WITH WEB STANDARDS

ASP.NET CONSULTING SERVICEShttp://[email protected]

Page 3: Health Monitoring
Page 4: Health Monitoring
Page 5: Health Monitoring

9 times of out 10

there’s nothing you can do

Page 6: Health Monitoring

But…

You must know about it

Page 7: Health Monitoring

Exception handling “greatest hits”

Page 8: Health Monitoring

Why I think “trying again” is a bad idea.

Page 9: Health Monitoring

catch (Exception ex)

{

string txt = ex.Message;

}

Exhibit A: a meaningless assignment

Page 10: Health Monitoring

catch (Exception XXX)

{

string txt = XXX.Message;

}

Exhibit B: an adult version of the same

Page 11: Health Monitoring

catch (Exception ex)

{

return false;

}

Exhibit C: a “magic” return value

Page 12: Health Monitoring

catch (Exception ex)

{

res = -1;

}

Exhibit D: C++ blues

Page 13: Health Monitoring

catch (Exception ex)

{

}

Exhibit E: horrible exception swallowing

Page 14: Health Monitoring

catch { }

Exhibit F: same

Page 15: Health Monitoring

catch (Exception Ex)

{

int i;

i=0;

}

Exhibit G: spinning one’s wheels

Page 16: Health Monitoring

catch (Exception ex)

{

throw ex;

}

Exhibit H: you gain what again?

Page 17: Health Monitoring

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

Why so averse to exceptions?

Page 19: Health Monitoring

Set up a custom error page

<customErrorsdefaultRedirect="~/errors/GenericError.aspx" mode="RemoteOnly" />

Page 20: Health Monitoring

Save yourself embarrassment

Page 21: Health Monitoring

So what is Health Monitoring about?

Page 22: Health Monitoring
Page 23: Health Monitoring

The “what”

What do you want to be notified about?

Page 24: Health Monitoring
Page 25: Health Monitoring

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

DemoCustom events

Page 27: Health Monitoring

The “how”

How do you want them delivered?

Page 28: Health Monitoring

ASP.NET 2.0 ships with the following providers:

• Windows Event Log• SQL Server• E-mail• WMI• Diagnostics Tracing

Page 29: Health Monitoring
Page 30: Health Monitoring

Custom providersLook it up ;)

Page 31: Health Monitoring
Page 32: Health Monitoring

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

BufferingLook it up ;)

Page 34: Health Monitoring

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

DemoA simple exception thrown and written to the system event log.

Page 36: Health Monitoring

TipRemember to deploy with debug symbols.

Page 37: Health Monitoring

Health Monitoring as a convenient way to keep track of whose fault it is.

Page 38: Health Monitoring

Questions