]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/metrics/doc.go
[dev.typeparams] Merge branch 'master' into dev.typeparams
[gostls13.git] / src / runtime / metrics / doc.go
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 /*
6 Package metrics provides a stable interface to access implementation-defined
7 metrics exported by the Go runtime. This package is similar to existing functions
8 like runtime.ReadMemStats and debug.ReadGCStats, but significantly more general.
9
10 The set of metrics defined by this package may evolve as the runtime itself
11 evolves, and also enables variation across Go implementations, whose relevant
12 metric sets may not intersect.
13
14 Interface
15
16 Metrics are designated by a string key, rather than, for example, a field name in
17 a struct. The full list of supported metrics is always available in the slice of
18 Descriptions returned by All. Each Description also includes useful information
19 about the metric, such as how to display it (e.g. gauge vs. counter) and how difficult
20 or disruptive it is to obtain it (e.g. do you need to stop the world?).
21
22 Thus, users of this API are encouraged to sample supported metrics defined by the
23 slice returned by All to remain compatible across Go versions. Of course, situations
24 arise where reading specific metrics is critical. For these cases, users are
25 encouranged to use build tags, and although metrics may be deprecated and removed,
26 users should consider this to be an exceptional and rare event, coinciding with a
27 very large change in a particular Go implementation.
28
29 Each metric key also has a "kind" that describes the format of the metric's value.
30 In the interest of not breaking users of this package, the "kind" for a given metric
31 is guaranteed not to change. If it must change, then a new metric will be introduced
32 with a new key and a new "kind."
33
34 Metric key format
35
36 As mentioned earlier, metric keys are strings. Their format is simple and well-defined,
37 designed to be both human and machine readable. It is split into two components,
38 separated by a colon: a rooted path and a unit. The choice to include the unit in
39 the key is motivated by compatibility: if a metric's unit changes, its semantics likely
40 did also, and a new key should be introduced.
41
42 For more details on the precise definition of the metric key's path and unit formats, see
43 the documentation of the Name field of the Description struct.
44
45 Supported metrics
46
47         /gc/cycles/automatic:gc-cycles
48                 Count of completed GC cycles generated by the Go runtime.
49
50         /gc/cycles/forced:gc-cycles
51                 Count of completed GC cycles forced by the application.
52
53         /gc/cycles/total:gc-cycles
54                 Count of all completed GC cycles.
55
56         /gc/heap/allocs-by-size:objects
57                 Distribution of all objects allocated by approximate size.
58
59         /gc/heap/frees-by-size:objects
60                 Distribution of all objects freed by approximate size.
61
62         /gc/heap/goal:bytes
63                 Heap size target for the end of the GC cycle.
64
65         /gc/heap/objects:objects
66                 Number of objects, live or unswept, occupying heap memory.
67
68         /gc/pauses:seconds
69                 Distribution individual GC-related stop-the-world pause latencies.
70
71         /memory/classes/heap/free:bytes
72                 Memory that is completely free and eligible to be returned to
73                 the underlying system, but has not been. This metric is the
74                 runtime's estimate of free address space that is backed by
75                 physical memory.
76
77         /memory/classes/heap/objects:bytes
78                 Memory occupied by live objects and dead objects that have
79                 not yet been marked free by the garbage collector.
80
81         /memory/classes/heap/released:bytes
82                 Memory that is completely free and has been returned to
83                 the underlying system. This metric is the runtime's estimate of
84                 free address space that is still mapped into the process, but
85                 is not backed by physical memory.
86
87         /memory/classes/heap/stacks:bytes
88                 Memory allocated from the heap that is reserved for stack
89                 space. Not all of it is necessarily simultaneously in use, but
90                 it may not be used for any other purpose.
91
92         /memory/classes/heap/unused:bytes
93                 Memory that is reserved for heap objects but is otherwise not
94                 currently used to hold heap objects.
95
96         /memory/classes/metadata/mcache/free:bytes
97                 Memory that is reserved for runtime mcache structures, but
98                 not in-use.
99
100         /memory/classes/metadata/mcache/inuse:bytes
101                 Memory that is occupied by runtime mcache structures that
102                 are currently being used.
103
104         /memory/classes/metadata/mspan/free:bytes
105                 Memory that is reserved for runtime mspan structures, but
106                 not in-use.
107
108         /memory/classes/metadata/mspan/inuse:bytes
109                 Memory that is occupied by runtime mspan structures that are
110                 currently being used.
111
112         /memory/classes/metadata/other:bytes
113                 Memory that is reserved for or used to hold runtime
114                 metadata.
115
116         /memory/classes/os-stacks:bytes
117                 Stack memory allocated by the underlying operating system.
118
119         /memory/classes/other:bytes
120                 Memory used by execution trace buffers, structures for
121                 debugging the runtime, finalizer and profiler specials, and
122                 more.
123
124         /memory/classes/profiling/buckets:bytes
125                 Memory that is used by the stack trace hash map used for
126                 profiling.
127
128         /memory/classes/total:bytes
129                 All memory mapped by the Go runtime into the current process
130                 as read-write. Note that this does not include memory mapped
131                 by code called via cgo or via the syscall package.
132                 Sum of all metrics in /memory/classes.
133
134         /sched/goroutines:goroutines
135                 Count of live goroutines.
136 */
137 package metrics