Skip to content

Instantly share code, notes, and snippets.

@kevingosse
Created June 21, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevingosse/2ab6292556ca8d2cb6dd3f14fcecf5ec to your computer and use it in GitHub Desktop.
Save kevingosse/2ab6292556ca8d2cb6dd3f14fcecf5ec to your computer and use it in GitHub Desktop.
internal class StartupHook
{
public static void Initialize()
{
new Thread(PollGCMetrics)
{
IsBackground = true,
Name = "GCMetricsPoller"
}.Start();
}
private static void PollGCMetrics()
{
var dogstatsdConfig = new StatsdConfig
{
StatsdServerName = "127.0.0.1",
StatsdPort = 8125,
};
using var dogStatsdService = new DogStatsdService();
dogStatsdService.Configure(dogstatsdConfig);
while (true)
{
var gen0 = GC.CollectionCount(0);
var gen1 = GC.CollectionCount(1);
var gen2 = GC.CollectionCount(2);
dogStatsdService.Gauge("GC.Gen0", gen0);
dogStatsdService.Gauge("GC.Gen1", gen1);
dogStatsdService.Gauge("GC.Gen2", gen2);
Thread.Sleep(1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment