Skip to content

search-for-the-one/Neo.ClrCounters

Repository files navigation

Neo.ClrCounters

With this library, you can trace CLR events (garbage collection and exception), with Event Pipe.

The original idea is from here.

How to use this library?

  • Add nuget library Neo2.ClrCounters to your project.
  • Add services.AddClrCounters() to enable CLR Counters.
  • Create class GarbageCollectionEventHandler and implement interface IGarbageCollectionEventHandler.
  • Add services.AddGarbageCollection<GarbageCollectionEventHandler>() to enable garbage collection events monitor.
  • Create class ExceptionEventHandler and implement interface IExceptionEventHandler.
  • Add services.AddGarbageCollection<ExceptionEventHandler>() to enable exception events monitor.
  • You can create and add multiple garbage collection and exception event handler class.
  • Start ClrEventProcessor with following code.
    public class ClrCountersApp : IConsoleApp
    {
        private readonly IClrEventProcessor clrEventProcessor;

        public ClrCountersApp(IClrEventProcessor clrEventProcessor) => this.clrEventProcessor = clrEventProcessor;

        public async Task Run() => StartClrCounters();

        private void StartClrCounters() => 
            new Thread(() => clrEventProcessor.Start()) {Priority = ThreadPriority.Highest, IsBackground = true}.Start();
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages