• Frugal Cafe
  • Posts
  • FC72: How to implement and use your own EventSource

FC72: How to implement and use your own EventSource

Generating your own ETW events

ETW tracing is a great source of performance data on Windows platforms. Commonly used ETW events including CPU samples, file/disk IO, network IO, .Net Runtime events, .Net Framework events, Asp.Net events, etc.

You can also generate your own ETW events from your source code and then use them for performance/non-performance investigations. In the .Net world, System.Diagnostics.Tracing.EventSource is the base class for generating custom ETW events.

Here is a simple example for Frugal Cafe:

Sample usage:

Output for normal run:

The event source is not enabled, so the added logging statements would not affect the performance of the code.

To enable it in PerfView, add:

Or you can also use its GUID. Here are the events captured: