Browse DevX
Sign up for e-mail newsletters from DevX


The Enterprise Instrumentation Framework : Page 5

The Enterprise Instrumentation Framework (EIF) provides an easy-to-use and unified API for writing trace messages out to any and all event sinks including: the event log, WMI, text files, MSMQ, etc.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Request-based Event Tracing
Your support team (or end users) will not know the intricate details of your application (as in its classes/types, methods, etc.). Therefore, the typical trace message may have little meaning to them. However, your users are well-aware of the services your application provides. For instance, they know your application allows them to "Edit a Customer" or "Submit a Purchase Order", etc. By knowing only these services of your application, the support organization should be able to turn on diagnostic information based on these contextual elements. In addition, your application should be able to trace a business process, request, or transaction from start to finish as one message (or set of messages). To accomplish this feat, the EIF provides request-based event tracing. This is truly one of the most exciting elements of the EIF. With request-based event tracing, you can wrap trace events into a single context which, in turn, maps to a business process flow in your application. This context can then be consumed by tools that correlate messages at the request level. You can easily create a tool that shows all failed requests to add a new order. EIF's output event tracing would let you drill into the failed requests to provide full details of the failure regardless of the number of method calls involved (or cross-process calls for that matter).

Figure 3: A single request set of messages.
You can easily implement your own request-based event tracing. First, create an instance of the RequestTrace class. Constructing this class implicitly starts the request trace (you do not make a call to a Start method). All trace messages raised once the RequestTrace class has been created are wrapped inside this request context. That's it! Even calls to methods that knew nothing of this context at design time will see their TraceMessageEvent.Raise calls get automatically wrapped into this context. To close the context (or end the request) you simply call the Dispose method of the RequestTrace class. An example of this is provided inside of Listing 1. At runtime, each event is tagged with the request context and the request sequence number, giving you the ability to correlate the messages as a logical unit (by writing or purchasing a tool). Figure 3 illustrates these messages grouped together inside the event log.

Event Tracing in Distributed Environments An enterprise application these days spans multiple layers and it is likely that some of these layers will be on physically-separate machines or even geo-graphically distributed. Request-based tracing takes this into account because the RequestTrace class can have its context flow across machine boundaries.

With Request-based event tracing, you can wrap trace events into a single context (which maps to a business process flow in your application)... This is truly one the most exciting elements of the EIF.
To do so, request tracing implements .NET's Remoting infrastructure. Information about a request is stored in the LogicalCallContext class which flows along the path of execution—crossing context, application, process, and machine boundaries. It is therefore particularly suitable for storing information about a request. However, the use of the remoting infrastructure limits the cross-boundary requests to managed code. Access to native code and Web services currently does not support the LogicalCallContext class and thus request-based tracing will not work in these scenarios.

In addition, as requests flow across each machine, each event that is raised will log to a local trace log. Therefore, a request that spans three machines will have its messages spanning the same three machines. What you will need is a means to aggregated and analyze these requests in one place (perhaps SQL Server). The EIF is simple but powerful. Using the EIF, you can group trace messages to form a logical unit that maps back to an actual business process your administrators and users can understand. Use the EIF to keep your application running smoothly and keep you writing code rather than troubleshooting production snafus.

Mike Snell, Microsoft Regional Director (RD) and MCSD. Mike has over 12 years of experience writing and designing software. His broad range of experience covers creating enterprise-level, Web-based systems as well as commercial applications using the Microsoft platform. Reach him at mike@brilliantSTORM.com.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date