aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/metrics/sample.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-07-01 16:02:42 +0000
committerMichael Knyszek <mknyszek@google.com>2020-10-26 18:29:05 +0000
commitb08dfbaa439e4e396b979e02ea2e7d36972e8b7a (patch)
tree20fbf60331aeb10a72f74625c45f4b0bcb3ca527 /src/runtime/metrics/sample.go
parent79781e8dd382ac34e502ed6a088dff6860a08c05 (diff)
downloadgo-b08dfbaa439e4e396b979e02ea2e7d36972e8b7a.tar.xz
runtime,runtime/metrics: add memory metrics
This change adds support for a variety of runtime memory metrics and contains the base implementation of Read for the runtime/metrics package, which lives in the runtime. It also adds testing infrastructure for the metrics package, and a bunch of format and documentation tests. For #37112. Change-Id: I16a2c4781eeeb2de0abcb045c15105f1210e2d8a Reviewed-on: https://go-review.googlesource.com/c/go/+/247041 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/metrics/sample.go')
-rw-r--r--src/runtime/metrics/sample.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/metrics/sample.go b/src/runtime/metrics/sample.go
index c7a3fc424a..b4b0979aa6 100644
--- a/src/runtime/metrics/sample.go
+++ b/src/runtime/metrics/sample.go
@@ -4,6 +4,11 @@
package metrics
+import (
+ _ "runtime" // depends on the runtime via a linkname'd function
+ "unsafe"
+)
+
// Sample captures a single metric sample.
type Sample struct {
// Name is the name of the metric sampled.
@@ -16,6 +21,9 @@ type Sample struct {
Value Value
}
+// Implemented in the runtime.
+func runtime_readMetrics(unsafe.Pointer, int, int)
+
// Read populates each Value field in the given slice of metric samples.
//
// Desired metrics should be present in the slice with the appropriate name.
@@ -25,5 +33,5 @@ type Sample struct {
// will have the value populated as KindBad to indicate that the name is
// unknown.
func Read(m []Sample) {
- panic("unimplemented")
+ runtime_readMetrics(unsafe.Pointer(&m[0]), len(m), cap(m))
}