...

Source file src/runtime/metrics/description.go

Documentation: runtime/metrics

     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  package metrics
     6  
     7  // Description describes a runtime metric.
     8  type Description struct {
     9  	// Name is the full name of the metric which includes the unit.
    10  	//
    11  	// The format of the metric may be described by the following regular expression.
    12  	//
    13  	// 	^(?P<name>/[^:]+):(?P<unit>[^:*/]+(?:[*/][^:*/]+)*)$
    14  	//
    15  	// The format splits the name into two components, separated by a colon: a path which always
    16  	// starts with a /, and a machine-parseable unit. The name may contain any valid Unicode
    17  	// codepoint in between / characters, but by convention will try to stick to lowercase
    18  	// characters and hyphens. An example of such a path might be "/memory/heap/free".
    19  	//
    20  	// The unit is by convention a series of lowercase English unit names (singular or plural)
    21  	// without prefixes delimited by '*' or '/'. The unit names may contain any valid Unicode
    22  	// codepoint that is not a delimiter.
    23  	// Examples of units might be "seconds", "bytes", "bytes/second", "cpu-seconds",
    24  	// "byte*cpu-seconds", and "bytes/second/second".
    25  	//
    26  	// For histograms, multiple units may apply. For instance, the units of the buckets and
    27  	// the count. By convention, for histograms, the units of the count are always "samples"
    28  	// with the type of sample evident by the metric's name, while the unit in the name
    29  	// specifies the buckets' unit.
    30  	//
    31  	// A complete name might look like "/memory/heap/free:bytes".
    32  	Name string
    33  
    34  	// Description is an English language sentence describing the metric.
    35  	Description string
    36  
    37  	// Kind is the kind of value for this metric.
    38  	//
    39  	// The purpose of this field is to allow users to filter out metrics whose values are
    40  	// types which their application may not understand.
    41  	Kind ValueKind
    42  
    43  	// Cumulative is whether or not the metric is cumulative. If a cumulative metric is just
    44  	// a single number, then it increases monotonically. If the metric is a distribution,
    45  	// then each bucket count increases monotonically.
    46  	//
    47  	// This flag thus indicates whether or not it's useful to compute a rate from this value.
    48  	Cumulative bool
    49  }
    50  
    51  // The English language descriptions below must be kept in sync with the
    52  // descriptions of each metric in doc.go.
    53  var allDesc = []Description{
    54  	{
    55  		Name:        "/cgo/go-to-c-calls:calls",
    56  		Description: "Count of calls made from Go to C by the current process.",
    57  		Kind:        KindUint64,
    58  		Cumulative:  true,
    59  	},
    60  	{
    61  		Name:        "/gc/cycles/automatic:gc-cycles",
    62  		Description: "Count of completed GC cycles generated by the Go runtime.",
    63  		Kind:        KindUint64,
    64  		Cumulative:  true,
    65  	},
    66  	{
    67  		Name:        "/gc/cycles/forced:gc-cycles",
    68  		Description: "Count of completed GC cycles forced by the application.",
    69  		Kind:        KindUint64,
    70  		Cumulative:  true,
    71  	},
    72  	{
    73  		Name:        "/gc/cycles/total:gc-cycles",
    74  		Description: "Count of all completed GC cycles.",
    75  		Kind:        KindUint64,
    76  		Cumulative:  true,
    77  	},
    78  	{
    79  		Name: "/gc/heap/allocs-by-size:bytes",
    80  		Description: "Distribution of heap allocations by approximate size. " +
    81  			"Note that this does not include tiny objects as defined by " +
    82  			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
    83  		Kind:       KindFloat64Histogram,
    84  		Cumulative: true,
    85  	},
    86  	{
    87  		Name:        "/gc/heap/allocs:bytes",
    88  		Description: "Cumulative sum of memory allocated to the heap by the application.",
    89  		Kind:        KindUint64,
    90  		Cumulative:  true,
    91  	},
    92  	{
    93  		Name: "/gc/heap/allocs:objects",
    94  		Description: "Cumulative count of heap allocations triggered by the application. " +
    95  			"Note that this does not include tiny objects as defined by " +
    96  			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
    97  		Kind:       KindUint64,
    98  		Cumulative: true,
    99  	},
   100  	{
   101  		Name: "/gc/heap/frees-by-size:bytes",
   102  		Description: "Distribution of freed heap allocations by approximate size. " +
   103  			"Note that this does not include tiny objects as defined by " +
   104  			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
   105  		Kind:       KindFloat64Histogram,
   106  		Cumulative: true,
   107  	},
   108  	{
   109  		Name:        "/gc/heap/frees:bytes",
   110  		Description: "Cumulative sum of heap memory freed by the garbage collector.",
   111  		Kind:        KindUint64,
   112  		Cumulative:  true,
   113  	},
   114  	{
   115  		Name: "/gc/heap/frees:objects",
   116  		Description: "Cumulative count of heap allocations whose storage was freed " +
   117  			"by the garbage collector. " +
   118  			"Note that this does not include tiny objects as defined by " +
   119  			"/gc/heap/tiny/allocs:objects, only tiny blocks.",
   120  		Kind:       KindUint64,
   121  		Cumulative: true,
   122  	},
   123  	{
   124  		Name:        "/gc/heap/goal:bytes",
   125  		Description: "Heap size target for the end of the GC cycle.",
   126  		Kind:        KindUint64,
   127  	},
   128  	{
   129  		Name:        "/gc/heap/objects:objects",
   130  		Description: "Number of objects, live or unswept, occupying heap memory.",
   131  		Kind:        KindUint64,
   132  	},
   133  	{
   134  		Name: "/gc/heap/tiny/allocs:objects",
   135  		Description: "Count of small allocations that are packed together into blocks. " +
   136  			"These allocations are counted separately from other allocations " +
   137  			"because each individual allocation is not tracked by the runtime, " +
   138  			"only their block. Each block is already accounted for in " +
   139  			"allocs-by-size and frees-by-size.",
   140  		Kind:       KindUint64,
   141  		Cumulative: true,
   142  	},
   143  	{
   144  		Name: "/gc/limiter/last-enabled:gc-cycle",
   145  		Description: "GC cycle the last time the GC CPU limiter was enabled. " +
   146  			"This metric is useful for diagnosing the root cause of an out-of-memory " +
   147  			"error, because the limiter trades memory for CPU time when the GC's CPU " +
   148  			"time gets too high. This is most likely to occur with use of SetMemoryLimit. " +
   149  			"The first GC cycle is cycle 1, so a value of 0 indicates that it was never enabled.",
   150  		Kind: KindUint64,
   151  	},
   152  	{
   153  		Name:        "/gc/pauses:seconds",
   154  		Description: "Distribution individual GC-related stop-the-world pause latencies.",
   155  		Kind:        KindFloat64Histogram,
   156  		Cumulative:  true,
   157  	},
   158  	{
   159  		Name:        "/gc/stack/starting-size:bytes",
   160  		Description: "The stack size of new goroutines.",
   161  		Kind:        KindUint64,
   162  		Cumulative:  false,
   163  	},
   164  	{
   165  		Name: "/memory/classes/heap/free:bytes",
   166  		Description: "Memory that is completely free and eligible to be returned to the underlying system, " +
   167  			"but has not been. This metric is the runtime's estimate of free address space that is backed by " +
   168  			"physical memory.",
   169  		Kind: KindUint64,
   170  	},
   171  	{
   172  		Name:        "/memory/classes/heap/objects:bytes",
   173  		Description: "Memory occupied by live objects and dead objects that have not yet been marked free by the garbage collector.",
   174  		Kind:        KindUint64,
   175  	},
   176  	{
   177  		Name: "/memory/classes/heap/released:bytes",
   178  		Description: "Memory that is completely free and has been returned to the underlying system. This " +
   179  			"metric is the runtime's estimate of free address space that is still mapped into the process, " +
   180  			"but is not backed by physical memory.",
   181  		Kind: KindUint64,
   182  	},
   183  	{
   184  		Name:        "/memory/classes/heap/stacks:bytes",
   185  		Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.",
   186  		Kind:        KindUint64,
   187  	},
   188  	{
   189  		Name:        "/memory/classes/heap/unused:bytes",
   190  		Description: "Memory that is reserved for heap objects but is not currently used to hold heap objects.",
   191  		Kind:        KindUint64,
   192  	},
   193  	{
   194  		Name:        "/memory/classes/metadata/mcache/free:bytes",
   195  		Description: "Memory that is reserved for runtime mcache structures, but not in-use.",
   196  		Kind:        KindUint64,
   197  	},
   198  	{
   199  		Name:        "/memory/classes/metadata/mcache/inuse:bytes",
   200  		Description: "Memory that is occupied by runtime mcache structures that are currently being used.",
   201  		Kind:        KindUint64,
   202  	},
   203  	{
   204  		Name:        "/memory/classes/metadata/mspan/free:bytes",
   205  		Description: "Memory that is reserved for runtime mspan structures, but not in-use.",
   206  		Kind:        KindUint64,
   207  	},
   208  	{
   209  		Name:        "/memory/classes/metadata/mspan/inuse:bytes",
   210  		Description: "Memory that is occupied by runtime mspan structures that are currently being used.",
   211  		Kind:        KindUint64,
   212  	},
   213  	{
   214  		Name:        "/memory/classes/metadata/other:bytes",
   215  		Description: "Memory that is reserved for or used to hold runtime metadata.",
   216  		Kind:        KindUint64,
   217  	},
   218  	{
   219  		Name:        "/memory/classes/os-stacks:bytes",
   220  		Description: "Stack memory allocated by the underlying operating system.",
   221  		Kind:        KindUint64,
   222  	},
   223  	{
   224  		Name:        "/memory/classes/other:bytes",
   225  		Description: "Memory used by execution trace buffers, structures for debugging the runtime, finalizer and profiler specials, and more.",
   226  		Kind:        KindUint64,
   227  	},
   228  	{
   229  		Name:        "/memory/classes/profiling/buckets:bytes",
   230  		Description: "Memory that is used by the stack trace hash map used for profiling.",
   231  		Kind:        KindUint64,
   232  	},
   233  	{
   234  		Name:        "/memory/classes/total:bytes",
   235  		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.",
   236  		Kind:        KindUint64,
   237  	},
   238  	{
   239  		Name:        "/sched/gomaxprocs:threads",
   240  		Description: "The current runtime.GOMAXPROCS setting, or the number of operating system threads that can execute user-level Go code simultaneously.",
   241  		Kind:        KindUint64,
   242  	},
   243  	{
   244  		Name:        "/sched/goroutines:goroutines",
   245  		Description: "Count of live goroutines.",
   246  		Kind:        KindUint64,
   247  	},
   248  	{
   249  		Name:        "/sched/latencies:seconds",
   250  		Description: "Distribution of the time goroutines have spent in the scheduler in a runnable state before actually running.",
   251  		Kind:        KindFloat64Histogram,
   252  	},
   253  }
   254  
   255  // All returns a slice of containing metric descriptions for all supported metrics.
   256  func All() []Description {
   257  	return allDesc
   258  }
   259  

View as plain text