out.scalar = uint64(gcController.memoryLimit.Load())
},
},
+ "/gc/gogc:percent": {
+ compute: func(in *statAggregate, out *metricValue) {
+ out.kind = metricKindUint64
+ out.scalar = uint64(gcController.gcPercent.Load())
+ },
+ },
"/gc/heap/live:bytes": {
deps: makeStatDepSet(heapStatsDep),
compute: func(in *statAggregate, out *metricValue) {
Kind: KindUint64,
Cumulative: true,
},
+ {
+ Name: "/gc/gogc:percent",
+ Description: "Heap size target percentage configured by the user, otherwise 100. This " +
+ "value is set by the GOGC environment variable, and the runtime/debug.SetGCPercent " +
+ "function.",
+ Kind: KindUint64,
+ },
{
Name: "/gc/gomemlimit:bytes",
Description: "Go runtime memory limit configured by the user, otherwise " +
/gc/cycles/total:gc-cycles
Count of all completed GC cycles.
+ /gc/gogc:percent
+ Heap size target percentage configured by the user, otherwise
+ 100. This value is set by the GOGC environment variable, and the
+ runtime/debug.SetGCPercent function.
+
/gc/gomemlimit:bytes
Go runtime memory limit configured by the user, otherwise
math.MaxInt64. This value is set by the GOMEMLIMIT environment
oldLimit := debug.SetMemoryLimit(limit)
defer debug.SetMemoryLimit(oldLimit)
+ // Set an GC percent to check the metric for it
+ gcPercent := 99
+ oldGCPercent := debug.SetGCPercent(gcPercent)
+ defer debug.SetGCPercent(oldGCPercent)
+
// Tests whether readMetrics produces values aligning
// with ReadMemStats while the world is stopped.
var mstats runtime.MemStats
checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapObjects)
case "/gc/heap/goal:bytes":
checkUint64(t, name, samples[i].Value.Uint64(), mstats.NextGC)
+ case "/gc/gogc:percent":
+ checkUint64(t, name, samples[i].Value.Uint64(), uint64(gcPercent))
case "/gc/cycles/automatic:gc-cycles":
checkUint64(t, name, samples[i].Value.Uint64(), uint64(mstats.NumGC-mstats.NumForcedGC))
case "/gc/cycles/forced:gc-cycles":