/ClrEvents

Source code based on TraceEvent to listen to CLR events at runtime

Primary LanguageC#

ClrEvents

Source code based on TraceEvent to listen to CLR events at runtime.

Introduction

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)

Source Code

The Events\ClrEtw Visual Studio solution contains different projects:

  1. ClrCounters: .NET Standard assembly to easily listen to CLR events with TraceEvent (.NET Core and Framework) or EventPipe (.NET Core only).

  2. ConsoleListener: Demo console application that uses 'ClrCounters' to display CLR details of a running application.

  3. NaiveListener: Demo console application that displays raw CLR events with TraceEvent.

  4. Simulator: Console application used to simulate interesting behaviours (contention, exceptions, allocations, thread pool usage).

  5. 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.

  6. GcLogger: Console application used to test GcLog.

  7. EventPipeGcLogger: Console application used to test EventPipeGcLog (.NET Core 3.0.100).

  8. AllocationTickProfiler: simple memory profiler using AllocationTick event.

  9. SampledObjectAllocationProfiler: simple memory profiler using SampledObjectAllocation(High/Low) events.

The Counters\EventPipeCounters Visual Studio solution contains different projets

  1. Counters.RuntimeClient: Helper classes to easily get .NET Core counters; including .csv file automatic creation.

  2. SimpleCounters: sample application to use CsvCounterListener and CounterMonitor helper classes.

  3. 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.