Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created December 5, 2025 08:02
Show Gist options
  • Select an option

  • Save wullemsb/e43ca6e7a3275cd467aad06b35898bd9 to your computer and use it in GitHub Desktop.

Select an option

Save wullemsb/e43ca6e7a3275cd467aad06b35898bd9 to your computer and use it in GitHub Desktop.
public class RequestsMeter
{
private static readonly Meter s_meter = new Meter("MyCompany.MyApp.Requests", "1.0.0");
private static readonly Counter<long> s_requestCounter =
s_meter.CreateCounter<long>("request-count", description: "Total number of requests");
private static readonly ObservableGauge<int> s_queueLengthGauge =
s_meter.CreateObservableGauge("queue-length",
() => GetQueueLength(),
description: "Current queue length");
public static void RecordRequest()
{
s_requestCounter.Add(1);
}
private static int GetQueueLength()
{
// TODO: Add implementation
return Random.Shared.Next(0, 100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment