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:
-
ClrCounters
: .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 'ClrCounters' to display CLR details of a running application. -
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.
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: unfortunately, no nuget package yet. So just recompiled it from github.