out.scalar = in.sysStats.heapGoal
},
},
+ "/gc/gomemlimit:bytes": {
+ compute: func(in *statAggregate, out *metricValue) {
+ out.kind = metricKindUint64
+ out.scalar = uint64(gcController.memoryLimit.Load())
+ },
+ },
"/gc/heap/live:bytes": {
deps: makeStatDepSet(heapStatsDep),
compute: func(in *statAggregate, out *metricValue) {
Kind: KindUint64,
Cumulative: true,
},
+ {
+ Name: "/gc/gomemlimit:bytes",
+ Description: "Go runtime memory limit configured by the user, otherwise " +
+ "math.MaxInt64. This value is set by the GOMEMLIMIT environment variable, and " +
+ "the runtime/debug.SetMemoryLimit function.",
+ Kind: KindUint64,
+ },
{
Name: "/gc/heap/allocs-by-size:bytes",
Description: "Distribution of heap allocations by approximate size. " +
/gc/cycles/total:gc-cycles
Count of all completed GC cycles.
+ /gc/gomemlimit:bytes
+ Go runtime memory limit configured by the user, otherwise
+ math.MaxInt64. This value is set by the GOMEMLIMIT environment
+ variable, and the runtime/debug.SetMemoryLimit function.
+
/gc/heap/allocs-by-size:bytes
Distribution of heap allocations by approximate size.
Bucket counts increase monotonically. Note that this does not
import (
"reflect"
"runtime"
+ "runtime/debug"
"runtime/metrics"
"sort"
"strings"
// Run a GC cycle to get some of the stats to be non-zero.
runtime.GC()
+ // Set an arbitrary memory limit to check the metric for it
+ limit := int64(512 * 1024 * 1024)
+ oldLimit := debug.SetMemoryLimit(limit)
+ defer debug.SetMemoryLimit(oldLimit)
+
// Tests whether readMetrics produces values aligning
// with ReadMemStats while the world is stopped.
var mstats runtime.MemStats
// Might happen if we don't call runtime.GC() above.
t.Error("live bytes is 0")
}
+ case "/gc/gomemlimit:bytes":
+ checkUint64(t, name, samples[i].Value.Uint64(), uint64(limit))
case "/gc/heap/objects:objects":
checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapObjects)
case "/gc/heap/goal:bytes":