Performance Metrics

Tracking system metrics such as gc, memory and cpu usage is very useful to compare against feature usage and other metrics to identify possible bottlenecks.

Toggly makes use of .net's built-in Performance Counters, and enables you to monitor any metrics exposed through Performance Counters, whether out-of-the-box or custom.

Add Performance Metrics to your application

Install the Toggly.Metrics.SystemMetrics package

Install-Package Toggly.Metrics.SystemMetrics

Register collection of the performance metrics you want to collect.

The service takes in a Dictionary<Event Source Name, Dictionary<Counter Name, Metric Name in Toggly>>

services.AddPerformanceMetrics(new Dictionary<string, Dictionary<string, string>>
    {  "System.Runtime", new Dictionary<string, string>
            {"time-in-gc", "TimeInGC"},
            {"alloc-rate", "AllocationRate"},
            {"cpu-usage", "CpuUsage"},
            {"exception-count", "ExceptionCount"},
            {"gc-heap-size", "GCHeapSize"},
            {"working-set", "MemoryWorkingSet"},
    { "Microsoft.AspNetCore.Hosting", new Dictionary<string, string>
            { "requests-per-second", "RequestsPerSecond" },

A full list of well-known performance counters is available at

Last updated