Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Last active December 5, 2025 07:45
Show Gist options
  • Select an option

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

Select an option

Save wullemsb/100b29518494fef31c556baa379a2c5b to your computer and use it in GitHub Desktop.
public class RequestsMeter
{
private static readonly Meter _meter = new Meter("MyCompany.MyApp", "1.0.0");
private static readonly Counter<long> _requestCounter =
s_meter.CreateCounter<long>("request-count", description: "Total number of requests");
private static readonly ObservableGauge<int> _queueLengthGauge =
s_meter.CreateObservableGauge("queue-length",
() => GetQueueLength(),
description: "Current queue length");
public static void RecordRequest()
{
_requestCounter.Add(1);
}
private static int GetQueueLength()
{
// 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