Better Tracing And Instrumentation For .NET Apps

| by Roopesh Shenoy Follow 0 Followers on Jul 16, 2012. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

EventSource and EventListener, introduced in .NET 4.5, provide a simple mechanism for applications to trace their events in Event Tracing for Windows (ETW). Combined with a analysis tool such as PerfView, this allows for better tracing of .NET apps.

.NET 4.5 introduces the EventSource class which provides a base class for developers to inherit and write their own Event Sources. Developers can then add a new method for every different type of event they want to log - these methods can be called from the application at the appropriate locations. Internally, these methods will call the base method WriteEvent() which in-turn sends the events to EventListeners that have subscribed, including the built-in listener that sends its logging messages to the ETW. Vance Morrison describes this in detail. 

As mentioned in a reference guide “Strongly Typed Events (EasyETW)” posted by Vance -

ETW is a high performance eventing system for windows which is used extensively in both the windows kernel as well as many windows subsystems. These built-in ETW sources provide wonderful ‘low level’ value (indicating where CPU, Disk, and network activities occur), and EventSource builds on this by allowing programmers to mark ‘high level’ semantic actions (like a user command, or a high level event), and thus assign resource consumption to high level tasks.

You can also implement custom EventListeners which can do things other than sending info to the ETW – for example, if for silverlight apps, you want to send the trace data over the network to the host machine.

PerfView is a performance analysis tool from Microsoft. Deployed as a single exe, it supports both CPU and Memory investigations of any application, but it also has some useful features especially for profiling managed code. Learn more about how to use this tool through these videos posted by Vance. 

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you