简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM