]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/metrics/doc.go
runtime/metrics: add /gc/scan/globals:bytes
[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 // Note: run 'go generate' (which will run 'go test -generate') to update the "Supported metrics" list.
6 //go:generate go test -run=Docs -generate
7
8 /*
9 Package metrics provides a stable interface to access implementation-defined
10 metrics exported by the Go runtime. This package is similar to existing functions
11 like [runtime.ReadMemStats] and [debug.ReadGCStats], but significantly more general.
12
13 The set of metrics defined by this package may evolve as the runtime itself
14 evolves, and also enables variation across Go implementations, whose relevant
15 metric sets may not intersect.
16
17 # Interface
18
19 Metrics are designated by a string key, rather than, for example, a field name in
20 a struct. The full list of supported metrics is always available in the slice of
21 Descriptions returned by All. Each Description also includes useful information
22 about the metric.
23
24 Thus, users of this API are encouraged to sample supported metrics defined by the
25 slice returned by All to remain compatible across Go versions. Of course, situations
26 arise where reading specific metrics is critical. For these cases, users are
27 encouraged to use build tags, and although metrics may be deprecated and removed,
28 users should consider this to be an exceptional and rare event, coinciding with a
29 very large change in a particular Go implementation.
30
31 Each metric key also has a "kind" that describes the format of the metric's value.
32 In the interest of not breaking users of this package, the "kind" for a given metric
33 is guaranteed not to change. If it must change, then a new metric will be introduced
34 with a new key and a new "kind."
35
36 # Metric key format
37
38 As mentioned earlier, metric keys are strings. Their format is simple and well-defined,
39 designed to be both human and machine readable. It is split into two components,
40 separated by a colon: a rooted path and a unit. The choice to include the unit in
41 the key is motivated by compatibility: if a metric's unit changes, its semantics likely
42 did also, and a new key should be introduced.
43
44 For more details on the precise definition of the metric key's path and unit formats, see
45 the documentation of the Name field of the Description struct.
46
47 # A note about floats
48
49 This package supports metrics whose values have a floating-point representation. In
50 order to improve ease-of-use, this package promises to never produce the following
51 classes of floating-point values: NaN, infinity.
52
53 # Supported metrics
54
55 Below is the full list of supported metrics, ordered lexicographically.
56
57         /cgo/go-to-c-calls:calls
58                 Count of calls made from Go to C by the current process.
59
60         /cpu/classes/gc/mark/assist:cpu-seconds
61                 Estimated total CPU time goroutines spent performing GC
62                 tasks to assist the GC and prevent it from falling behind the
63                 application. This metric is an overestimate, and not directly
64                 comparable to system CPU time measurements. Compare only with
65                 other /cpu/classes metrics.
66
67         /cpu/classes/gc/mark/dedicated:cpu-seconds
68                 Estimated total CPU time spent performing GC tasks on processors
69                 (as defined by GOMAXPROCS) dedicated to those tasks. This
70                 includes time spent with the world stopped due to the GC. This
71                 metric is an overestimate, and not directly comparable to system
72                 CPU time measurements. Compare only with other /cpu/classes
73                 metrics.
74
75         /cpu/classes/gc/mark/idle:cpu-seconds
76                 Estimated total CPU time spent performing GC tasks on spare CPU
77                 resources that the Go scheduler could not otherwise find a use
78                 for. This should be subtracted from the total GC CPU time to
79                 obtain a measure of compulsory GC CPU time. This metric is an
80                 overestimate, and not directly comparable to system CPU time
81                 measurements. Compare only with other /cpu/classes metrics.
82
83         /cpu/classes/gc/pause:cpu-seconds
84                 Estimated total CPU time spent with the application paused by
85                 the GC. Even if only one thread is running during the pause,
86                 this is computed as GOMAXPROCS times the pause latency because
87                 nothing else can be executing. This is the exact sum of samples
88                 in /gc/pause:seconds if each sample is multiplied by GOMAXPROCS
89                 at the time it is taken. This metric is an overestimate,
90                 and not directly comparable to system CPU time measurements.
91                 Compare only with other /cpu/classes metrics.
92
93         /cpu/classes/gc/total:cpu-seconds
94                 Estimated total CPU time spent performing GC tasks. This metric
95                 is an overestimate, and not directly comparable to system CPU
96                 time measurements. Compare only with other /cpu/classes metrics.
97                 Sum of all metrics in /cpu/classes/gc.
98
99         /cpu/classes/idle:cpu-seconds
100                 Estimated total available CPU time not spent executing
101                 any Go or Go runtime code. In other words, the part of
102                 /cpu/classes/total:cpu-seconds that was unused. This metric is
103                 an overestimate, and not directly comparable to system CPU time
104                 measurements. Compare only with other /cpu/classes metrics.
105
106         /cpu/classes/scavenge/assist:cpu-seconds
107                 Estimated total CPU time spent returning unused memory to the
108                 underlying platform in response eagerly in response to memory
109                 pressure. This metric is an overestimate, and not directly
110                 comparable to system CPU time measurements. Compare only with
111                 other /cpu/classes metrics.
112
113         /cpu/classes/scavenge/background:cpu-seconds
114                 Estimated total CPU time spent performing background tasks to
115                 return unused memory to the underlying platform. This metric is
116                 an overestimate, and not directly comparable to system CPU time
117                 measurements. Compare only with other /cpu/classes metrics.
118
119         /cpu/classes/scavenge/total:cpu-seconds
120                 Estimated total CPU time spent performing tasks that return
121                 unused memory to the underlying platform. This metric is an
122                 overestimate, and not directly comparable to system CPU time
123                 measurements. Compare only with other /cpu/classes metrics.
124                 Sum of all metrics in /cpu/classes/scavenge.
125
126         /cpu/classes/total:cpu-seconds
127                 Estimated total available CPU time for user Go code or the Go
128                 runtime, as defined by GOMAXPROCS. In other words, GOMAXPROCS
129                 integrated over the wall-clock duration this process has been
130                 executing for. This metric is an overestimate, and not directly
131                 comparable to system CPU time measurements. Compare only with
132                 other /cpu/classes metrics. Sum of all metrics in /cpu/classes.
133
134         /cpu/classes/user:cpu-seconds
135                 Estimated total CPU time spent running user Go code. This may
136                 also include some small amount of time spent in the Go runtime.
137                 This metric is an overestimate, and not directly comparable
138                 to system CPU time measurements. Compare only with other
139                 /cpu/classes metrics.
140
141         /gc/cycles/automatic:gc-cycles
142                 Count of completed GC cycles generated by the Go runtime.
143
144         /gc/cycles/forced:gc-cycles
145                 Count of completed GC cycles forced by the application.
146
147         /gc/cycles/total:gc-cycles
148                 Count of all completed GC cycles.
149
150         /gc/gogc:percent
151                 Heap size target percentage configured by the user, otherwise
152                 100. This value is set by the GOGC environment variable, and the
153                 runtime/debug.SetGCPercent function.
154
155         /gc/gomemlimit:bytes
156                 Go runtime memory limit configured by the user, otherwise
157                 math.MaxInt64. This value is set by the GOMEMLIMIT environment
158                 variable, and the runtime/debug.SetMemoryLimit function.
159
160         /gc/heap/allocs-by-size:bytes
161                 Distribution of heap allocations by approximate size.
162                 Bucket counts increase monotonically. Note that this does not
163                 include tiny objects as defined by /gc/heap/tiny/allocs:objects,
164                 only tiny blocks.
165
166         /gc/heap/allocs:bytes
167                 Cumulative sum of memory allocated to the heap by the
168                 application.
169
170         /gc/heap/allocs:objects
171                 Cumulative count of heap allocations triggered by the
172                 application. Note that this does not include tiny objects as
173                 defined by /gc/heap/tiny/allocs:objects, only tiny blocks.
174
175         /gc/heap/frees-by-size:bytes
176                 Distribution of freed heap allocations by approximate size.
177                 Bucket counts increase monotonically. Note that this does not
178                 include tiny objects as defined by /gc/heap/tiny/allocs:objects,
179                 only tiny blocks.
180
181         /gc/heap/frees:bytes
182                 Cumulative sum of heap memory freed by the garbage collector.
183
184         /gc/heap/frees:objects
185                 Cumulative count of heap allocations whose storage was freed
186                 by the garbage collector. Note that this does not include tiny
187                 objects as defined by /gc/heap/tiny/allocs:objects, only tiny
188                 blocks.
189
190         /gc/heap/goal:bytes
191                 Heap size target for the end of the GC cycle.
192
193         /gc/heap/live:bytes
194                 Heap memory occupied by live objects that were marked by the
195                 previous GC.
196
197         /gc/heap/objects:objects
198                 Number of objects, live or unswept, occupying heap memory.
199
200         /gc/heap/tiny/allocs:objects
201                 Count of small allocations that are packed together into blocks.
202                 These allocations are counted separately from other allocations
203                 because each individual allocation is not tracked by the
204                 runtime, only their block. Each block is already accounted for
205                 in allocs-by-size and frees-by-size.
206
207         /gc/limiter/last-enabled:gc-cycle
208                 GC cycle the last time the GC CPU limiter was enabled.
209                 This metric is useful for diagnosing the root cause of an
210                 out-of-memory error, because the limiter trades memory for CPU
211                 time when the GC's CPU time gets too high. This is most likely
212                 to occur with use of SetMemoryLimit. The first GC cycle is cycle
213                 1, so a value of 0 indicates that it was never enabled.
214
215         /gc/pauses:seconds
216                 Distribution of individual GC-related stop-the-world pause
217                 latencies. Bucket counts increase monotonically.
218
219         /gc/scan/globals:bytes
220                 The total amount of global variable space that is scannable.
221
222         /gc/scan/stack:bytes
223                 The number of bytes of stack that were scanned last GC cycle.
224
225         /gc/stack/starting-size:bytes
226                 The stack size of new goroutines.
227
228         /godebug/non-default-behavior/execerrdot:events
229                 The number of non-default behaviors executed by the os/exec
230                 package due to a non-default GODEBUG=execerrdot=... setting.
231
232         /godebug/non-default-behavior/http2client:events
233                 The number of non-default behaviors executed by the net/http
234                 package due to a non-default GODEBUG=http2client=... setting.
235
236         /godebug/non-default-behavior/http2server:events
237                 The number of non-default behaviors executed by the net/http
238                 package due to a non-default GODEBUG=http2server=... setting.
239
240         /godebug/non-default-behavior/installgoroot:events
241                 The number of non-default behaviors executed by the go/build
242                 package due to a non-default GODEBUG=installgoroot=... setting.
243
244         /godebug/non-default-behavior/jstmpllitinterp:events
245                 The number of non-default behaviors executed by
246                 the html/template package due to a non-default
247                 GODEBUG=jstmpllitinterp=... setting.
248
249         /godebug/non-default-behavior/multipartmaxheaders:events
250                 The number of non-default behaviors executed by
251                 the mime/multipart package due to a non-default
252                 GODEBUG=multipartmaxheaders=... setting.
253
254         /godebug/non-default-behavior/multipartmaxparts:events
255                 The number of non-default behaviors executed by
256                 the mime/multipart package due to a non-default
257                 GODEBUG=multipartmaxparts=... setting.
258
259         /godebug/non-default-behavior/panicnil:events
260                 The number of non-default behaviors executed by the runtime
261                 package due to a non-default GODEBUG=panicnil=... setting.
262
263         /godebug/non-default-behavior/randautoseed:events
264                 The number of non-default behaviors executed by the math/rand
265                 package due to a non-default GODEBUG=randautoseed=... setting.
266
267         /godebug/non-default-behavior/tarinsecurepath:events
268                 The number of non-default behaviors executed by the archive/tar
269                 package due to a non-default GODEBUG=tarinsecurepath=...
270                 setting.
271
272         /godebug/non-default-behavior/x509sha1:events
273                 The number of non-default behaviors executed by the crypto/x509
274                 package due to a non-default GODEBUG=x509sha1=... setting.
275
276         /godebug/non-default-behavior/x509usefallbackroots:events
277                 The number of non-default behaviors executed by the crypto/x509
278                 package due to a non-default GODEBUG=x509usefallbackroots=...
279                 setting.
280
281         /godebug/non-default-behavior/zipinsecurepath:events
282                 The number of non-default behaviors executed by the archive/zip
283                 package due to a non-default GODEBUG=zipinsecurepath=...
284                 setting.
285
286         /memory/classes/heap/free:bytes
287                 Memory that is completely free and eligible to be returned to
288                 the underlying system, but has not been. This metric is the
289                 runtime's estimate of free address space that is backed by
290                 physical memory.
291
292         /memory/classes/heap/objects:bytes
293                 Memory occupied by live objects and dead objects that have not
294                 yet been marked free by the garbage collector.
295
296         /memory/classes/heap/released:bytes
297                 Memory that is completely free and has been returned to the
298                 underlying system. This metric is the runtime's estimate of free
299                 address space that is still mapped into the process, but is not
300                 backed by physical memory.
301
302         /memory/classes/heap/stacks:bytes
303                 Memory allocated from the heap that is reserved for stack space,
304                 whether or not it is currently in-use.
305
306         /memory/classes/heap/unused:bytes
307                 Memory that is reserved for heap objects but is not currently
308                 used to hold heap objects.
309
310         /memory/classes/metadata/mcache/free:bytes
311                 Memory that is reserved for runtime mcache structures, but not
312                 in-use.
313
314         /memory/classes/metadata/mcache/inuse:bytes
315                 Memory that is occupied by runtime mcache structures that are
316                 currently being used.
317
318         /memory/classes/metadata/mspan/free:bytes
319                 Memory that is reserved for runtime mspan structures, but not
320                 in-use.
321
322         /memory/classes/metadata/mspan/inuse:bytes
323                 Memory that is occupied by runtime mspan structures that are
324                 currently being used.
325
326         /memory/classes/metadata/other:bytes
327                 Memory that is reserved for or used to hold runtime metadata.
328
329         /memory/classes/os-stacks:bytes
330                 Stack memory allocated by the underlying operating system.
331
332         /memory/classes/other:bytes
333                 Memory used by execution trace buffers, structures for debugging
334                 the runtime, finalizer and profiler specials, and more.
335
336         /memory/classes/profiling/buckets:bytes
337                 Memory that is used by the stack trace hash map used for
338                 profiling.
339
340         /memory/classes/total:bytes
341                 All memory mapped by the Go runtime into the current process
342                 as read-write. Note that this does not include memory mapped
343                 by code called via cgo or via the syscall package. Sum of all
344                 metrics in /memory/classes.
345
346         /sched/gomaxprocs:threads
347                 The current runtime.GOMAXPROCS setting, or the number of
348                 operating system threads that can execute user-level Go code
349                 simultaneously.
350
351         /sched/goroutines:goroutines
352                 Count of live goroutines.
353
354         /sched/latencies:seconds
355                 Distribution of the time goroutines have spent in the scheduler
356                 in a runnable state before actually running. Bucket counts
357                 increase monotonically.
358
359         /sync/mutex/wait/total:seconds
360                 Approximate cumulative time goroutines have spent blocked
361                 on a sync.Mutex or sync.RWMutex. This metric is useful for
362                 identifying global changes in lock contention. Collect a mutex
363                 or block profile using the runtime/pprof package for more
364                 detailed contention data.
365 */
366 package metrics