Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created December 5, 2025 07:05
Show Gist options
  • Select an option

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

Select an option

Save wullemsb/c70d1af521bef658edab08c6c6b37204 to your computer and use it in GitHub Desktop.
[EventSource(Name = "MyCompany.MyApp")]
public sealed class MyEventSource : EventSource
{
public static readonly MyEventSource Log = new MyEventSource();
private EventCounter _requestCounter;
private PollingCounter _queueLengthCounter;
private MyEventSource()
{
_requestCounter = new EventCounter("request-count", this);
_queueLengthCounter = new PollingCounter("queue-length", this,
() => GetQueueLength());
}
public void RecordRequest()
{
_requestCounter.WriteMetric(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment