Created
June 21, 2020 12:15
-
-
Save kevingosse/2ab6292556ca8d2cb6dd3f14fcecf5ec to your computer and use it in GitHub Desktop.
This file contains 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
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