mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime/metrics: add package interface
This change creates the runtime/metrics package and adds the initial interface as laid out in the design document. For #37112. Change-Id: I202dcee08ab008dd63bf96f7a4162f5b5f813637 Reviewed-on: https://go-review.googlesource.com/c/go/+/247040 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
c02134abb0
commit
2159c26ceb
6 changed files with 232 additions and 0 deletions
52
src/runtime/metrics/description.go
Normal file
52
src/runtime/metrics/description.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package metrics
|
||||
|
||||
// Description describes a runtime metric.
|
||||
type Description struct {
|
||||
// Name is the full name of the metric which includes the unit.
|
||||
//
|
||||
// The format of the metric may be described by the following regular expression.
|
||||
//
|
||||
// ^(?P<name>/[^:]+):(?P<unit>[^:*\/]+(?:[*\/][^:*\/]+)*)$
|
||||
//
|
||||
// The format splits the name into two components, separated by a colon: a path which always
|
||||
// starts with a /, and a machine-parseable unit. The name may contain any valid Unicode
|
||||
// codepoint in between / characters, but by convention will try to stick to lowercase
|
||||
// characters and hyphens. An example of such a path might be "/memory/heap/free".
|
||||
//
|
||||
// The unit is by convention a series of lowercase English unit names (singular or plural)
|
||||
// without prefixes delimited by '*' or '/'. The unit names may contain any valid Unicode
|
||||
// codepoint that is not a delimiter.
|
||||
// Examples of units might be "seconds", "bytes", "bytes/second", "cpu-seconds",
|
||||
// "byte*cpu-seconds", and "bytes/second/second".
|
||||
//
|
||||
// A complete name might look like "/memory/heap/free:bytes".
|
||||
Name string
|
||||
|
||||
// Kind is the kind of value for this metric.
|
||||
//
|
||||
// The purpose of this field is to allow users to filter out metrics whose values are
|
||||
// types which their application may not understand.
|
||||
Kind ValueKind
|
||||
|
||||
// Cumulative is whether or not the metric is cumulative. If a cumulative metric is just
|
||||
// a single number, then it increases monotonically. If the metric is a distribution,
|
||||
// then each bucket count increases monotonically.
|
||||
//
|
||||
// This flag thus indicates whether or not it's useful to compute a rate from this value.
|
||||
Cumulative bool
|
||||
|
||||
// StopTheWorld is whether or not the metric requires a stop-the-world
|
||||
// event in order to collect it.
|
||||
StopTheWorld bool
|
||||
}
|
||||
|
||||
var allDesc = []Description{}
|
||||
|
||||
// All returns a slice of containing metric descriptions for all supported metrics.
|
||||
func All() []Description {
|
||||
return allDesc
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue