toggly
  • What is toggly?
  • 🚀Getting started
    • Creating your first project
    • Using our Feature Flag Demo
    • Inviting Your Team
    • API Documentation
  • 🔘Feature Flags
    • Feature Flags in C# / .NET
      • Views
      • Controllers & Actions
      • Dependency Injection
      • Routing
      • IFeatureManagerSnapshot
      • Persistent Flags Across Requests
      • Disabled Action Handling
      • State Change Handlers
      • Custom Context
      • Snapshot Providers
        • RavenDB
        • Entity Framework
      • Debugging Endpoint
      • Serving Front-end Flags
      • Undefined Features In Development
      • Deployments and Version
    • Feature Flags in Vue.js
      • Feature Component
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in JavaScript
      • Directly Checking a Flag
      • Definition Refresh
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in Flutter
      • Feature Widget
      • Directly Checking a Flag
      • Users and Rollouts
      • Flag Defaults
    • Feature Flags in HTML/CSS
  • 📈Metrics
    • Metrics in C# / .NET
      • Feature Usage
      • Business Metrics
      • Performance Metrics
  • 👩‍💻Use Cases
    • For Engineers
      • Develop continuously, turn on when ready
    • For Product Managers
      • Measure Feature Impact
    • For Agile Teams
      • Faster QA Cycles
      • Streamline Your Releases
Powered by GitBook
On this page

Was this helpful?

  1. Metrics
  2. Metrics in C# / .NET

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" },
        }
    }
});
PreviousBusiness MetricsNextFor Engineers

Last updated 2 years ago

Was this helpful?

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

📈
https://learn.microsoft.com/en-us/dotnet/core/diagnostics/available-counters