Tracing and Instrumentation refers to the process of adding code to your application in order to locate and diagnose errors, identify application status, and measure performance. Instrumentation is about adding the tracing code, and tracing is about directing and otherwise controlling the information generated by the tracing code. Needless to say, there's a third step: analyzing the generated information.
In a way, this process is similar to the use of black boxes in commercial and many private aircraft. Black boxes consist of a Flight Data Recorder (FDR) and a Cockpit Voice Recorder (CVR) that together record a large amount of information about the state of an aircraft and the behavior of its flight crew. Since their implementation, they have been invaluable in identifying and diagnosing nearly all of the problems that have caused airplane incidents and crashes.
You can think of adding tracing code as the equivalent of creating an FDR for your application. This is important because monitoring, supporting, and maintaining a software system, especially a distributed application, usually takes far more time than its original development. Typically, 80% of the effort put into an application goes into support after the application has gone into production. Developers often ignore this support burden because much of it is mostly invisible to them, but in the distributed and more complex world of .NET, these support costs need to be actively contained. It's no good building your company's best decision-support application (or trading application, or whatever) if it proves impossible to keep the system running in a cost-effective way. This problem becomes even worse if you build a system that your customers then come to depend on ”at that point, you're unlikely to have the luxury of reengineering your code to reduce its support burden .
This chapter looks at useful types of diagnostic information, who is likely to use this information, how to use the diagnostic tools available in .NET, and how to control the data that is generated. It deals in detail with the following subjects:
Types of diagnostic information that are useful to record
Tracing in VB .NET, including recording, listening, and configuration
Tracing with ASP .NET
Using custom performance counters with Performance Monitor
Tracing in ASP .NET applications is covered in Chapter 9, which covers the debugging of ASP .NET applications.