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
  • MeasureAsync
  • ObserveAsync
  • IncrementCounterAsync

Was this helpful?

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

Business Metrics

Metrics represent any numbers you want to track over time originating from your application. They are used in conjunction with experiments to provide value beyond just tracking.

Keeping to the Open Telemetry standards, we support 3 types of metrics, all available via the IMetricsService interface

Metrics are aggregated in the Metrics service, and sent to Toggly's API on an interval. Currently it's at 1 minute, but this may change. Metrics are kept at this granularity for a few days, then rolled up into hourly buckets, and eventually daily buckets.

MeasureAsync

Increment the value of a defined metric.

A value that is aggregated over time. This is more akin to the trip odometer on a car, it represents a value over some defined range.

public class AccountController : Controller
{
    private readonly IMetricsService _metricsService;

    public AccountController(IMetricsService metricsService)
    {
        _metricsService = metricsService;
    }

    public async Task<IActionResult> SignIn(SignInModel model)
    {
        ...
        await _metricsService.MeasureAsync("SignIn", 1);
        ...
    }
}

ObserveAsync

Record a value at an instant in time.

Captures the current value at a point in time, like a fuel gauge in a vehicle

public class AccountController : Controller
{
    private readonly IMetricsService _metricsService;

    public AccountController(IMetricsService metricsService)
    {
        _metricsService = metricsService;
    }

    public async Task<IActionResult> SignIn(SignInModel model)
    {
        ...
        await _metricsService.ObserveAsync("TotalActiveUsers", 30);
        ...
    }
}

IncrementCounterAsync

Increment a named counter

A value that is summed over time – you can think of this like an odometer on a car


public class SignupController : Controller
{
    private readonly IMetricsService _metricsService;

    public SignupController(IMetricsService metricsService)
    {
        _metricsService = metricsService;
    }

    public async Task<IActionResult> SignIn(SignUpModel model)
    {
        await _metricsService.IncrementCounterAsync("TotalSignups", 1);
    }
}
PreviousFeature UsageNextPerformance Metrics

Last updated 1 year ago

Was this helpful?

📈