Last active
December 5, 2025 07:45
-
-
Save wullemsb/100b29518494fef31c556baa379a2c5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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