Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collect real time GC metrics - Golang

Is there a straightforward way in Go to get information about the GC and heap sizes in order to expose them to a monitoring dashboard. I had a look at the runtime package but there doesnt seem to be anything that does that there. Ideally this shouldnt require any overhead like running the application in profiling mode, etc, but should be production ready.

like image 324
Feras Avatar asked Mar 14 '23 00:03

Feras


1 Answers

You can use the GODEBUG=gctrace=1 to get continuous output, which is documented in the runtime package.

Otherwise, you need to collect information from runtime.MemStats and debug.GCStats.

like image 137
JimB Avatar answered Mar 21 '23 06:03

JimB