aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/metrics/description.go
blob: aea51c7f7567b480552022bce14e9b27883f96f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
// 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

import "internal/godebugs"

// 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".
	//
	// For histograms, multiple units may apply. For instance, the units of the buckets and
	// the count. By convention, for histograms, the units of the count are always "samples"
	// with the type of sample evident by the metric's name, while the unit in the name
	// specifies the buckets' unit.
	//
	// A complete name might look like "/memory/heap/free:bytes".
	Name string

	// Description is an English language sentence describing the metric.
	Description 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
}

// The English language descriptions below must be kept in sync with the
// descriptions of each metric in doc.go by running 'go generate'.
var allDesc = []Description{
	{
		Name:        "/cgo/go-to-c-calls:calls",
		Description: "Count of calls made from Go to C by the current process.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name: "/cpu/classes/gc/mark/assist:cpu-seconds",
		Description: "Estimated total CPU time goroutines spent performing GC tasks " +
			"to assist the GC and prevent it from falling behind the application. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/gc/mark/dedicated:cpu-seconds",
		Description: "Estimated total CPU time spent performing GC tasks on " +
			"processors (as defined by GOMAXPROCS) dedicated to those tasks. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/gc/mark/idle:cpu-seconds",
		Description: "Estimated total CPU time spent performing GC tasks on " +
			"spare CPU resources that the Go scheduler could not otherwise find " +
			"a use for. This should be subtracted from the total GC CPU time to " +
			"obtain a measure of compulsory GC CPU time. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/gc/pause:cpu-seconds",
		Description: "Estimated total CPU time spent with the application paused by " +
			"the GC. Even if only one thread is running during the pause, this is " +
			"computed as GOMAXPROCS times the pause latency because nothing else " +
			"can be executing. This is the exact sum of samples in /gc/pause:seconds " +
			"if each sample is multiplied by GOMAXPROCS at the time it is taken. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/gc/total:cpu-seconds",
		Description: "Estimated total CPU time spent performing GC tasks. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics. Sum of all metrics in /cpu/classes/gc.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/idle:cpu-seconds",
		Description: "Estimated total available CPU time not spent executing any Go or Go runtime code. " +
			"In other words, the part of /cpu/classes/total:cpu-seconds that was unused. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/scavenge/assist:cpu-seconds",
		Description: "Estimated total CPU time spent returning unused memory to the " +
			"underlying platform in response eagerly in response to memory pressure. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/scavenge/background:cpu-seconds",
		Description: "Estimated total CPU time spent performing background tasks " +
			"to return unused memory to the underlying platform. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/scavenge/total:cpu-seconds",
		Description: "Estimated total CPU time spent performing tasks that return " +
			"unused memory to the underlying platform. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics. Sum of all metrics in /cpu/classes/scavenge.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/total:cpu-seconds",
		Description: "Estimated total available CPU time for user Go code " +
			"or the Go runtime, as defined by GOMAXPROCS. In other words, GOMAXPROCS " +
			"integrated over the wall-clock duration this process has been executing for. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics. Sum of all metrics in /cpu/classes.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name: "/cpu/classes/user:cpu-seconds",
		Description: "Estimated total CPU time spent running user Go code. This may " +
			"also include some small amount of time spent in the Go runtime. " +
			"This metric is an overestimate, and not directly comparable to " +
			"system CPU time measurements. Compare only with other /cpu/classes " +
			"metrics.",
		Kind:       KindFloat64,
		Cumulative: true,
	},
	{
		Name:        "/gc/cycles/automatic:gc-cycles",
		Description: "Count of completed GC cycles generated by the Go runtime.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name:        "/gc/cycles/forced:gc-cycles",
		Description: "Count of completed GC cycles forced by the application.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name:        "/gc/cycles/total:gc-cycles",
		Description: "Count of all completed GC cycles.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name: "/gc/gogc:percent",
		Description: "Heap size target percentage configured by the user, otherwise 100. This " +
			"value is set by the GOGC environment variable, and the runtime/debug.SetGCPercent " +
			"function.",
		Kind: KindUint64,
	},
	{
		Name: "/gc/gomemlimit:bytes",
		Description: "Go runtime memory limit configured by the user, otherwise " +
			"math.MaxInt64. This value is set by the GOMEMLIMIT environment variable, and " +
			"the runtime/debug.SetMemoryLimit function.",
		Kind: KindUint64,
	},
	{
		Name: "/gc/heap/allocs-by-size:bytes",
		Description: "Distribution of heap allocations by approximate size. " +
			"Bucket counts increase monotonically. " +
			"Note that this does not include tiny objects as defined by " +
			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
		Kind:       KindFloat64Histogram,
		Cumulative: true,
	},
	{
		Name:        "/gc/heap/allocs:bytes",
		Description: "Cumulative sum of memory allocated to the heap by the application.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name: "/gc/heap/allocs:objects",
		Description: "Cumulative count of heap allocations triggered by the application. " +
			"Note that this does not include tiny objects as defined by " +
			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
		Kind:       KindUint64,
		Cumulative: true,
	},
	{
		Name: "/gc/heap/frees-by-size:bytes",
		Description: "Distribution of freed heap allocations by approximate size. " +
			"Bucket counts increase monotonically. " +
			"Note that this does not include tiny objects as defined by " +
			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
		Kind:       KindFloat64Histogram,
		Cumulative: true,
	},
	{
		Name:        "/gc/heap/frees:bytes",
		Description: "Cumulative sum of heap memory freed by the garbage collector.",
		Kind:        KindUint64,
		Cumulative:  true,
	},
	{
		Name: "/gc/heap/frees:objects",
		Description: "Cumulative count of heap allocations whose storage was freed " +
			"by the garbage collector. " +
			"Note that this does not include tiny objects as defined by " +
			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
		Kind:       KindUint64,
		Cumulative: true,
	},
	{
		Name:        "/gc/heap/goal:bytes",
		Description: "Heap size target for the end of the GC cycle.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/heap/live:bytes",
		Description: "Heap memory occupied by live objects that were marked by the previous GC.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/heap/objects:objects",
		Description: "Number of objects, live or unswept, occupying heap memory.",
		Kind:        KindUint64,
	},
	{
		Name: "/gc/heap/tiny/allocs:objects",
		Description: "Count of small allocations that are packed together into blocks. " +
			"These allocations are counted separately from other allocations " +
			"because each individual allocation is not tracked by the runtime, " +
			"only their block. Each block is already accounted for in " +
			"allocs-by-size and frees-by-size.",
		Kind:       KindUint64,
		Cumulative: true,
	},
	{
		Name: "/gc/limiter/last-enabled:gc-cycle",
		Description: "GC cycle the last time the GC CPU limiter was enabled. " +
			"This metric is useful for diagnosing the root cause of an out-of-memory " +
			"error, because the limiter trades memory for CPU time when the GC's CPU " +
			"time gets too high. This is most likely to occur with use of SetMemoryLimit. " +
			"The first GC cycle is cycle 1, so a value of 0 indicates that it was never enabled.",
		Kind: KindUint64,
	},
	{
		Name:        "/gc/pauses:seconds",
		Description: "Distribution of individual GC-related stop-the-world pause latencies. Bucket counts increase monotonically.",
		Kind:        KindFloat64Histogram,
		Cumulative:  true,
	},
	{
		Name:        "/gc/scan/globals:bytes",
		Description: "The total amount of global variable space that is scannable.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/scan/heap:bytes",
		Description: "The total amount of heap space that is scannable.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/scan/stack:bytes",
		Description: "The number of bytes of stack that were scanned last GC cycle.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/scan/total:bytes",
		Description: "The total amount space that is scannable. Sum of all metrics in /gc/scan.",
		Kind:        KindUint64,
	},
	{
		Name:        "/gc/stack/starting-size:bytes",
		Description: "The stack size of new goroutines.",
		Kind:        KindUint64,
		Cumulative:  false,
	},
	{
		Name: "/memory/classes/heap/free:bytes",
		Description: "Memory that is completely free and eligible to be returned to the underlying system, " +
			"but has not been. This metric is the runtime's estimate of free address space that is backed by " +
			"physical memory.",
		Kind: KindUint64,
	},
	{
		Name:        "/memory/classes/heap/objects:bytes",
		Description: "Memory occupied by live objects and dead objects that have not yet been marked free by the garbage collector.",
		Kind:        KindUint64,
	},
	{
		Name: "/memory/classes/heap/released:bytes",
		Description: "Memory that is completely free and has been returned to the underlying system. This " +
			"metric is the runtime's estimate of free address space that is still mapped into the process, " +
			"but is not backed by physical memory.",
		Kind: KindUint64,
	},
	{
		Name:        "/memory/classes/heap/stacks:bytes",
		Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/heap/unused:bytes",
		Description: "Memory that is reserved for heap objects but is not currently used to hold heap objects.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/metadata/mcache/free:bytes",
		Description: "Memory that is reserved for runtime mcache structures, but not in-use.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/metadata/mcache/inuse:bytes",
		Description: "Memory that is occupied by runtime mcache structures that are currently being used.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/metadata/mspan/free:bytes",
		Description: "Memory that is reserved for runtime mspan structures, but not in-use.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/metadata/mspan/inuse:bytes",
		Description: "Memory that is occupied by runtime mspan structures that are currently being used.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/metadata/other:bytes",
		Description: "Memory that is reserved for or used to hold runtime metadata.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/os-stacks:bytes",
		Description: "Stack memory allocated by the underlying operating system.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/other:bytes",
		Description: "Memory used by execution trace buffers, structures for debugging the runtime, finalizer and profiler specials, and more.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/profiling/buckets:bytes",
		Description: "Memory that is used by the stack trace hash map used for profiling.",
		Kind:        KindUint64,
	},
	{
		Name:        "/memory/classes/total:bytes",
		Description: "All memory mapped by the Go runtime into the current process as read-write. Note that this does not include memory mapped by code called via cgo or via the syscall package. Sum of all metrics in /memory/classes.",
		Kind:        KindUint64,
	},
	{
		Name:        "/sched/gomaxprocs:threads",
		Description: "The current runtime.GOMAXPROCS setting, or the number of operating system threads that can execute user-level Go code simultaneously.",
		Kind:        KindUint64,
	},
	{
		Name:        "/sched/goroutines:goroutines",
		Description: "Count of live goroutines.",
		Kind:        KindUint64,
	},
	{
		Name:        "/sched/latencies:seconds",
		Description: "Distribution of the time goroutines have spent in the scheduler in a runnable state before actually running. Bucket counts increase monotonically.",
		Kind:        KindFloat64Histogram,
		Cumulative:  true,
	},
	{
		Name:        "/sync/mutex/wait/total:seconds",
		Description: "Approximate cumulative time goroutines have spent blocked on a sync.Mutex or sync.RWMutex. This metric is useful for identifying global changes in lock contention. Collect a mutex or block profile using the runtime/pprof package for more detailed contention data.",
		Kind:        KindFloat64,
		Cumulative:  true,
	},
}

func init() {
	// Insert all the non-default-reporting GODEBUGs into the table,
	// preserving the overall sort order.
	i := 0
	for i < len(allDesc) && allDesc[i].Name < "/godebug/" {
		i++
	}
	more := make([]Description, i, len(allDesc)+len(godebugs.All))
	copy(more, allDesc)
	for _, info := range godebugs.All {
		if !info.Opaque {
			more = append(more, Description{
				Name: "/godebug/non-default-behavior/" + info.Name + ":events",
				Description: "The number of non-default behaviors executed by the " +
					info.Package + " package " + "due to a non-default " +
					"GODEBUG=" + info.Name + "=... setting.",
				Kind:       KindUint64,
				Cumulative: true,
			})
		}
	}
	allDesc = append(more, allDesc[i:]...)
}

// All returns a slice of containing metric descriptions for all supported metrics.
func All() []Description {
	return allDesc
}