]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/metrics/doc.go
runtime: add available godoc link
[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 metric
70                 is an overestimate, and not directly comparable to system CPU
71                 time measurements. Compare only with other /cpu/classes metrics.
72
73         /cpu/classes/gc/mark/idle:cpu-seconds
74                 Estimated total CPU time spent performing GC tasks on spare CPU
75                 resources that the Go scheduler could not otherwise find a use
76                 for. This should be subtracted from the total GC CPU time to
77                 obtain a measure of compulsory GC CPU time. This metric is an
78                 overestimate, and not directly comparable to system CPU time
79                 measurements. Compare only with other /cpu/classes metrics.
80
81         /cpu/classes/gc/pause:cpu-seconds
82                 Estimated total CPU time spent with the application paused by
83                 the GC. Even if only one thread is running during the pause,
84                 this is computed as GOMAXPROCS times the pause latency because
85                 nothing else can be executing. This is the exact sum of samples
86                 in /gc/pause:seconds if each sample is multiplied by GOMAXPROCS
87                 at the time it is taken. This metric is an overestimate,
88                 and not directly comparable to system CPU time measurements.
89                 Compare only with other /cpu/classes metrics.
90
91         /cpu/classes/gc/total:cpu-seconds
92                 Estimated total CPU time spent performing GC tasks. This metric
93                 is an overestimate, and not directly comparable to system CPU
94                 time measurements. Compare only with other /cpu/classes metrics.
95                 Sum of all metrics in /cpu/classes/gc.
96
97         /cpu/classes/idle:cpu-seconds
98                 Estimated total available CPU time not spent executing
99                 any Go or Go runtime code. In other words, the part of
100                 /cpu/classes/total:cpu-seconds that was unused. This metric is
101                 an overestimate, and not directly comparable to system CPU time
102                 measurements. Compare only with other /cpu/classes metrics.
103
104         /cpu/classes/scavenge/assist:cpu-seconds
105                 Estimated total CPU time spent returning unused memory to the
106                 underlying platform in response eagerly in response to memory
107                 pressure. This metric is an overestimate, and not directly
108                 comparable to system CPU time measurements. Compare only with
109                 other /cpu/classes metrics.
110
111         /cpu/classes/scavenge/background:cpu-seconds
112                 Estimated total CPU time spent performing background tasks to
113                 return unused memory to the underlying platform. This metric is
114                 an overestimate, and not directly comparable to system CPU time
115                 measurements. Compare only with other /cpu/classes metrics.
116
117         /cpu/classes/scavenge/total:cpu-seconds
118                 Estimated total CPU time spent performing tasks that return
119                 unused memory to the underlying platform. This metric is an
120                 overestimate, and not directly comparable to system CPU time
121                 measurements. Compare only with other /cpu/classes metrics.
122                 Sum of all metrics in /cpu/classes/scavenge.
123
124         /cpu/classes/total:cpu-seconds
125                 Estimated total available CPU time for user Go code or the Go
126                 runtime, as defined by GOMAXPROCS. In other words, GOMAXPROCS
127                 integrated over the wall-clock duration this process has been
128                 executing for. This metric is an overestimate, and not directly
129                 comparable to system CPU time measurements. Compare only with
130                 other /cpu/classes metrics. Sum of all metrics in /cpu/classes.
131
132         /cpu/classes/user:cpu-seconds
133                 Estimated total CPU time spent running user Go code. This may
134                 also include some small amount of time spent in the Go runtime.
135                 This metric is an overestimate, and not directly comparable
136                 to system CPU time measurements. Compare only with other
137                 /cpu/classes metrics.
138
139         /gc/cycles/automatic:gc-cycles
140                 Count of completed GC cycles generated by the Go runtime.
141
142         /gc/cycles/forced:gc-cycles
143                 Count of completed GC cycles forced by the application.
144
145         /gc/cycles/total:gc-cycles
146                 Count of all completed GC cycles.
147
148         /gc/gogc:percent
149                 Heap size target percentage configured by the user, otherwise
150                 100. This value is set by the GOGC environment variable, and the
151                 runtime/debug.SetGCPercent function.
152
153         /gc/gomemlimit:bytes
154                 Go runtime memory limit configured by the user, otherwise
155                 math.MaxInt64. This value is set by the GOMEMLIMIT environment
156                 variable, and the runtime/debug.SetMemoryLimit function.
157
158         /gc/heap/allocs-by-size:bytes
159                 Distribution of heap allocations by approximate size.
160                 Bucket counts increase monotonically. Note that this does not
161                 include tiny objects as defined by /gc/heap/tiny/allocs:objects,
162                 only tiny blocks.
163
164         /gc/heap/allocs:bytes
165                 Cumulative sum of memory allocated to the heap by the
166                 application.
167
168         /gc/heap/allocs:objects
169                 Cumulative count of heap allocations triggered by the
170                 application. Note that this does not include tiny objects as
171                 defined by /gc/heap/tiny/allocs:objects, only tiny blocks.
172
173         /gc/heap/frees-by-size:bytes
174                 Distribution of freed heap allocations by approximate size.
175                 Bucket counts increase monotonically. Note that this does not
176                 include tiny objects as defined by /gc/heap/tiny/allocs:objects,
177                 only tiny blocks.
178
179         /gc/heap/frees:bytes
180                 Cumulative sum of heap memory freed by the garbage collector.
181
182         /gc/heap/frees:objects
183                 Cumulative count of heap allocations whose storage was freed
184                 by the garbage collector. Note that this does not include tiny
185                 objects as defined by /gc/heap/tiny/allocs:objects, only tiny
186                 blocks.
187
188         /gc/heap/goal:bytes
189                 Heap size target for the end of the GC cycle.
190
191         /gc/heap/live:bytes
192                 Heap memory occupied by live objects that were marked by the
193                 previous GC.
194
195         /gc/heap/objects:objects
196                 Number of objects, live or unswept, occupying heap memory.
197
198         /gc/heap/tiny/allocs:objects
199                 Count of small allocations that are packed together into blocks.
200                 These allocations are counted separately from other allocations
201                 because each individual allocation is not tracked by the
202                 runtime, only their block. Each block is already accounted for
203                 in allocs-by-size and frees-by-size.
204
205         /gc/limiter/last-enabled:gc-cycle
206                 GC cycle the last time the GC CPU limiter was enabled.
207                 This metric is useful for diagnosing the root cause of an
208                 out-of-memory error, because the limiter trades memory for CPU
209                 time when the GC's CPU time gets too high. This is most likely
210                 to occur with use of SetMemoryLimit. The first GC cycle is cycle
211                 1, so a value of 0 indicates that it was never enabled.
212
213         /gc/pauses:seconds
214                 Distribution of individual GC-related stop-the-world pause
215                 latencies. Bucket counts increase monotonically.
216
217         /gc/scan/globals:bytes
218                 The total amount of global variable space that is scannable.
219
220         /gc/scan/heap:bytes
221                 The total amount of heap space that is scannable.
222
223         /gc/scan/stack:bytes
224                 The number of bytes of stack that were scanned last GC cycle.
225
226         /gc/scan/total:bytes
227                 The total amount space that is scannable. Sum of all metrics in
228                 /gc/scan.
229
230         /gc/stack/starting-size:bytes
231                 The stack size of new goroutines.
232
233         /godebug/non-default-behavior/execerrdot:events
234                 The number of non-default behaviors executed by the os/exec
235                 package due to a non-default GODEBUG=execerrdot=... setting.
236
237         /godebug/non-default-behavior/gocachehash:events
238                 The number of non-default behaviors executed by the cmd/go
239                 package due to a non-default GODEBUG=gocachehash=... setting.
240
241         /godebug/non-default-behavior/gocachetest:events
242                 The number of non-default behaviors executed by the cmd/go
243                 package due to a non-default GODEBUG=gocachetest=... setting.
244
245         /godebug/non-default-behavior/gocacheverify:events
246                 The number of non-default behaviors executed by the cmd/go
247                 package due to a non-default GODEBUG=gocacheverify=... setting.
248
249         /godebug/non-default-behavior/http2client:events
250                 The number of non-default behaviors executed by the net/http
251                 package due to a non-default GODEBUG=http2client=... setting.
252
253         /godebug/non-default-behavior/http2server:events
254                 The number of non-default behaviors executed by the net/http
255                 package due to a non-default GODEBUG=http2server=... setting.
256
257         /godebug/non-default-behavior/httplaxcontentlength:events
258                 The number of non-default behaviors executed by the net/http
259                 package due to a non-default GODEBUG=httplaxcontentlength=...
260                 setting.
261
262         /godebug/non-default-behavior/httpmuxgo121:events
263                 The number of non-default behaviors executed by the net/http
264                 package due to a non-default GODEBUG=httpmuxgo121=... setting.
265
266         /godebug/non-default-behavior/installgoroot:events
267                 The number of non-default behaviors executed by the go/build
268                 package due to a non-default GODEBUG=installgoroot=... setting.
269
270         /godebug/non-default-behavior/jstmpllitinterp:events
271                 The number of non-default behaviors executed by
272                 the html/template package due to a non-default
273                 GODEBUG=jstmpllitinterp=... setting.
274
275         /godebug/non-default-behavior/multipartmaxheaders:events
276                 The number of non-default behaviors executed by
277                 the mime/multipart package due to a non-default
278                 GODEBUG=multipartmaxheaders=... setting.
279
280         /godebug/non-default-behavior/multipartmaxparts:events
281                 The number of non-default behaviors executed by
282                 the mime/multipart package due to a non-default
283                 GODEBUG=multipartmaxparts=... setting.
284
285         /godebug/non-default-behavior/multipathtcp:events
286                 The number of non-default behaviors executed by the net package
287                 due to a non-default GODEBUG=multipathtcp=... setting.
288
289         /godebug/non-default-behavior/panicnil:events
290                 The number of non-default behaviors executed by the runtime
291                 package due to a non-default GODEBUG=panicnil=... setting.
292
293         /godebug/non-default-behavior/randautoseed:events
294                 The number of non-default behaviors executed by the math/rand
295                 package due to a non-default GODEBUG=randautoseed=... setting.
296
297         /godebug/non-default-behavior/tarinsecurepath:events
298                 The number of non-default behaviors executed by the archive/tar
299                 package due to a non-default GODEBUG=tarinsecurepath=...
300                 setting.
301
302         /godebug/non-default-behavior/tlsmaxrsasize:events
303                 The number of non-default behaviors executed by the crypto/tls
304                 package due to a non-default GODEBUG=tlsmaxrsasize=... setting.
305
306         /godebug/non-default-behavior/x509sha1:events
307                 The number of non-default behaviors executed by the crypto/x509
308                 package due to a non-default GODEBUG=x509sha1=... setting.
309
310         /godebug/non-default-behavior/x509usefallbackroots:events
311                 The number of non-default behaviors executed by the crypto/x509
312                 package due to a non-default GODEBUG=x509usefallbackroots=...
313                 setting.
314
315         /godebug/non-default-behavior/zipinsecurepath:events
316                 The number of non-default behaviors executed by the archive/zip
317                 package due to a non-default GODEBUG=zipinsecurepath=...
318                 setting.
319
320         /memory/classes/heap/free:bytes
321                 Memory that is completely free and eligible to be returned to
322                 the underlying system, but has not been. This metric is the
323                 runtime's estimate of free address space that is backed by
324                 physical memory.
325
326         /memory/classes/heap/objects:bytes
327                 Memory occupied by live objects and dead objects that have not
328                 yet been marked free by the garbage collector.
329
330         /memory/classes/heap/released:bytes
331                 Memory that is completely free and has been returned to the
332                 underlying system. This metric is the runtime's estimate of free
333                 address space that is still mapped into the process, but is not
334                 backed by physical memory.
335
336         /memory/classes/heap/stacks:bytes
337                 Memory allocated from the heap that is reserved for stack space,
338                 whether or not it is currently in-use. Currently, this
339                 represents all stack memory for goroutines. It also includes all
340                 OS thread stacks in non-cgo programs. Note that stacks may be
341                 allocated differently in the future, and this may change.
342
343         /memory/classes/heap/unused:bytes
344                 Memory that is reserved for heap objects but is not currently
345                 used to hold heap objects.
346
347         /memory/classes/metadata/mcache/free:bytes
348                 Memory that is reserved for runtime mcache structures, but not
349                 in-use.
350
351         /memory/classes/metadata/mcache/inuse:bytes
352                 Memory that is occupied by runtime mcache structures that are
353                 currently being used.
354
355         /memory/classes/metadata/mspan/free:bytes
356                 Memory that is reserved for runtime mspan structures, but not
357                 in-use.
358
359         /memory/classes/metadata/mspan/inuse:bytes
360                 Memory that is occupied by runtime mspan structures that are
361                 currently being used.
362
363         /memory/classes/metadata/other:bytes
364                 Memory that is reserved for or used to hold runtime metadata.
365
366         /memory/classes/os-stacks:bytes
367                 Stack memory allocated by the underlying operating system.
368                 In non-cgo programs this metric is currently zero. This may
369                 change in the future.In cgo programs this metric includes
370                 OS thread stacks allocated directly from the OS. Currently,
371                 this only accounts for one stack in c-shared and c-archive build
372                 modes, and other sources of stacks from the OS are not measured.
373                 This too may change in the future.
374
375         /memory/classes/other:bytes
376                 Memory used by execution trace buffers, structures for debugging
377                 the runtime, finalizer and profiler specials, and more.
378
379         /memory/classes/profiling/buckets:bytes
380                 Memory that is used by the stack trace hash map used for
381                 profiling.
382
383         /memory/classes/total:bytes
384                 All memory mapped by the Go runtime into the current process
385                 as read-write. Note that this does not include memory mapped
386                 by code called via cgo or via the syscall package. Sum of all
387                 metrics in /memory/classes.
388
389         /sched/gomaxprocs:threads
390                 The current runtime.GOMAXPROCS setting, or the number of
391                 operating system threads that can execute user-level Go code
392                 simultaneously.
393
394         /sched/goroutines:goroutines
395                 Count of live goroutines.
396
397         /sched/latencies:seconds
398                 Distribution of the time goroutines have spent in the scheduler
399                 in a runnable state before actually running. Bucket counts
400                 increase monotonically.
401
402         /sync/mutex/wait/total:seconds
403                 Approximate cumulative time goroutines have spent blocked
404                 on a sync.Mutex or sync.RWMutex. This metric is useful for
405                 identifying global changes in lock contention. Collect a mutex
406                 or block profile using the runtime/pprof package for more
407                 detailed contention data.
408 */
409 package metrics