mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/metrics: add the number of Go-to-C calls
For #47216. Change-Id: I1c2cd518e6ff510cc3ac8d8f72fd52eadcabc16c Reviewed-on: https://go-review.googlesource.com/c/go/+/404306 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
364ced6255
commit
9bd6e2776f
4 changed files with 17 additions and 0 deletions
|
|
@ -65,6 +65,12 @@ func initMetrics() {
|
||||||
|
|
||||||
timeHistBuckets = timeHistogramMetricsBuckets()
|
timeHistBuckets = timeHistogramMetricsBuckets()
|
||||||
metrics = map[string]metricData{
|
metrics = map[string]metricData{
|
||||||
|
"/cgo/go-to-c-calls:calls": {
|
||||||
|
compute: func(_ *statAggregate, out *metricValue) {
|
||||||
|
out.kind = metricKindUint64
|
||||||
|
out.scalar = uint64(NumCgoCall())
|
||||||
|
},
|
||||||
|
},
|
||||||
"/gc/cycles/automatic:gc-cycles": {
|
"/gc/cycles/automatic:gc-cycles": {
|
||||||
deps: makeStatDepSet(sysStatsDep),
|
deps: makeStatDepSet(sysStatsDep),
|
||||||
compute: func(in *statAggregate, out *metricValue) {
|
compute: func(in *statAggregate, out *metricValue) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,12 @@ type Description struct {
|
||||||
// The English language descriptions below must be kept in sync with the
|
// The English language descriptions below must be kept in sync with the
|
||||||
// descriptions of each metric in doc.go.
|
// descriptions of each metric in doc.go.
|
||||||
var allDesc = []Description{
|
var allDesc = []Description{
|
||||||
|
{
|
||||||
|
Name: "/cgo/go-to-c-calls:calls",
|
||||||
|
Description: "Count of calls made from Go to C by the current process.",
|
||||||
|
Kind: KindUint64,
|
||||||
|
Cumulative: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "/gc/cycles/automatic:gc-cycles",
|
Name: "/gc/cycles/automatic:gc-cycles",
|
||||||
Description: "Count of completed GC cycles generated by the Go runtime.",
|
Description: "Count of completed GC cycles generated by the Go runtime.",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ classes of floating-point values: NaN, infinity.
|
||||||
|
|
||||||
Below is the full list of supported metrics, ordered lexicographically.
|
Below is the full list of supported metrics, ordered lexicographically.
|
||||||
|
|
||||||
|
/cgo/go-to-c-calls:calls
|
||||||
|
Count of calls made from Go to C by the current process.
|
||||||
|
|
||||||
/gc/cycles/automatic:gc-cycles
|
/gc/cycles/automatic:gc-cycles
|
||||||
Count of completed GC cycles generated by the Go runtime.
|
Count of completed GC cycles generated by the Go runtime.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ func TestReadMetrics(t *testing.T) {
|
||||||
var mallocs, frees uint64
|
var mallocs, frees uint64
|
||||||
for i := range samples {
|
for i := range samples {
|
||||||
switch name := samples[i].Name; name {
|
switch name := samples[i].Name; name {
|
||||||
|
case "/cgo/go-to-c-calls:calls":
|
||||||
|
checkUint64(t, name, samples[i].Value.Uint64(), uint64(runtime.NumCgoCall()))
|
||||||
case "/memory/classes/heap/free:bytes":
|
case "/memory/classes/heap/free:bytes":
|
||||||
checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapIdle-mstats.HeapReleased)
|
checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapIdle-mstats.HeapReleased)
|
||||||
case "/memory/classes/heap/released:bytes":
|
case "/memory/classes/heap/released:bytes":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue