Skip to content
Snippets Groups Projects
Commit ece6ac4d authored by Michael Anthony Knyszek's avatar Michael Anthony Knyszek Committed by Michael Knyszek
Browse files

runtime/metrics: add gomaxprocs metric

For #47216.

Change-Id: Ib2d48c4583570a2dae9510a52d4c6ffc20161b31
Reviewed-on: https://go-review.googlesource.com/c/go/+/404305


Reviewed-by: default avatarDavid Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
parent 0f715f1a
Branches master
No related tags found
No related merge requests found
...@@ -280,6 +280,12 @@ func initMetrics() { ...@@ -280,6 +280,12 @@ func initMetrics() {
in.sysStats.gcMiscSys + in.sysStats.otherSys in.sysStats.gcMiscSys + in.sysStats.otherSys
}, },
}, },
"/sched/gomaxprocs:threads": {
compute: func(_ *statAggregate, out *metricValue) {
out.kind = metricKindUint64
out.scalar = uint64(gomaxprocs)
},
},
"/sched/goroutines:goroutines": { "/sched/goroutines:goroutines": {
compute: func(_ *statAggregate, out *metricValue) { compute: func(_ *statAggregate, out *metricValue) {
out.kind = metricKindUint64 out.kind = metricKindUint64
......
...@@ -220,6 +220,11 @@ var allDesc = []Description{ ...@@ -220,6 +220,11 @@ var allDesc = []Description{
Description: "All memory mapped by the Go runtime into the current process as read-write. Note that this does not include memory mapped by code called via cgo or via the syscall package. Sum of all metrics in /memory/classes.", Description: "All memory mapped by the Go runtime into the current process as read-write. Note that this does not include memory mapped by code called via cgo or via the syscall package. Sum of all metrics in /memory/classes.",
Kind: KindUint64, Kind: KindUint64,
}, },
{
Name: "/sched/gomaxprocs:threads",
Description: "The current runtime.GOMAXPROCS setting, or the number of operating system threads that can execute user-level Go code simultaneously.",
Kind: KindUint64,
},
{ {
Name: "/sched/goroutines:goroutines", Name: "/sched/goroutines:goroutines",
Description: "Count of live goroutines.", Description: "Count of live goroutines.",
......
...@@ -167,6 +167,11 @@ Below is the full list of supported metrics, ordered lexicographically. ...@@ -167,6 +167,11 @@ Below is the full list of supported metrics, ordered lexicographically.
by code called via cgo or via the syscall package. by code called via cgo or via the syscall package.
Sum of all metrics in /memory/classes. Sum of all metrics in /memory/classes.
/sched/gomaxprocs:threads
The current runtime.GOMAXPROCS setting, or the number of
operating system threads that can execute user-level Go code
simultaneously.
/sched/goroutines:goroutines /sched/goroutines:goroutines
Count of live goroutines. Count of live goroutines.
......
...@@ -223,6 +223,10 @@ func TestReadMetricsConsistency(t *testing.T) { ...@@ -223,6 +223,10 @@ func TestReadMetricsConsistency(t *testing.T) {
for i := range h.Counts { for i := range h.Counts {
gc.pauses += h.Counts[i] gc.pauses += h.Counts[i]
} }
case "/sched/gomaxprocs:threads":
if got, want := samples[i].Value.Uint64(), uint64(runtime.GOMAXPROCS(-1)); got != want {
t.Errorf("gomaxprocs doesn't match runtime.GOMAXPROCS: got %d, want %d", got, want)
}
case "/sched/goroutines:goroutines": case "/sched/goroutines:goroutines":
if samples[i].Value.Uint64() < 1 { if samples[i].Value.Uint64() < 1 {
t.Error("number of goroutines is less than one") t.Error("number of goroutines is less than one")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment