Source code based on TraceEvent to listen to CLR events at runtime.
Most of the code is detailed in the blog series related to CLR events:
Part 1: Replace .NET performance counters by CLR event tracing.
Part 2: Grab ETW Session, Providers and Events.
Part 3: Monitor Finalizers, contention and threads in your application.
Part 4: Spying on .NET Garbage Collector with TraceEvent.
Part 5: Building your own Java-like GC logs in .NET.
Part 6: Spying on .NET Garbage Collector with .NET Core EventPipes
Part 7: .NET Core Counters internals: how to integrate counters in your monitoring pipeline
Part 8: How to expose your custom counters in .NET Core
Part 9: Build your own .NET memory profiler in C# - allocations(1/2)
The Events\ClrEtw
Visual Studio solution contains different projects:
-
Events.Shared
: .NET Standard assembly to easily listen to CLR events with TraceEvent (.NET Core and Framework) or EventPipe (.NET Core only). -
ConsoleListener
: Demo console application that uses 'Events.Shared' to display CLR details of events emitted by a running .NET application including HTTP requests. -
NaiveListener
: Demo console application that displays raw CLR events with TraceEvent. -
Simulator
: Console application used to simulate interesting behaviours (contention, exceptions, allocations, thread pool usage). -
GcLog
: Helper classes to generate a log file containing one line per garbage collection happening in a .NET Application given its process ID. EtwGcLog is based on TraceEvent and listen to ETW events. -
GcLogger
: Console application used to test GcLog. -
EventPipeGcLogger
: Console application used to test EventPipeGcLog (.NET Core 3.0.100). -
AllocationTickProfiler
: simple memory profiler using AllocationTick event. -
SampledObjectAllocationProfiler
: simple memory profiler using SampledObjectAllocation(High/Low) events. -
dotnet-activity
: tool to encode and decode event activities GUID -
dotnet-http
: CLI tool to monitor HTTP requests live
The Counters\EventPipeCounters
Visual Studio solution contains different projets
-
Counters.RuntimeClient
: Helper classes to easily get .NET Core counters; including .csv file automatic creation. -
SimpleCounters
: sample application to use CsvCounterListener and CounterMonitor helper classes. -
CountersWebApp
: sample ASP.NET Core application to demonstrate custom counters about count/duration of requests processed with(out) GC.
Projects dependecies:
-
TraceEvent: C# library to listen to CLR events. Source code is available on Github.
-
Microsoft.Diagnostics.Tools.RuntimeClient: copied from github because it is supporting both ETW and EventPipe. For EventPipe only, use Microsoft.Diagnostics.NETCore.Client