| 1 |
// Copyright 2022 The Prometheus Authors |
| 2 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 |
// you may not use this file except in compliance with the License. |
| 4 |
// You may obtain a copy of the License at |
| 5 |
// |
| 6 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
// |
| 8 |
// Unless required by applicable law or agreed to in writing, software |
| 9 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 |
// See the License for the specific language governing permissions and |
| 12 |
// limitations under the License. |
| 13 |
|
| 14 |
//go:build go1.20 && !go1.21 |
| 15 |
// +build go1.20,!go1.21 |
| 16 |
|
| 17 |
package collectors |
| 18 |
|
| 19 |
func withAllMetrics() []string { |
| 20 |
return withBaseMetrics([]string{ |
| 21 |
"go_cgo_go_to_c_calls_calls_total", |
| 22 |
"go_cpu_classes_gc_mark_assist_cpu_seconds_total", |
| 23 |
"go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", |
| 24 |
"go_cpu_classes_gc_mark_idle_cpu_seconds_total", |
| 25 |
"go_cpu_classes_gc_pause_cpu_seconds_total", |
| 26 |
"go_cpu_classes_gc_total_cpu_seconds_total", |
| 27 |
"go_cpu_classes_idle_cpu_seconds_total", |
| 28 |
"go_cpu_classes_scavenge_assist_cpu_seconds_total", |
| 29 |
"go_cpu_classes_scavenge_background_cpu_seconds_total", |
| 30 |
"go_cpu_classes_scavenge_total_cpu_seconds_total", |
| 31 |
"go_cpu_classes_total_cpu_seconds_total", |
| 32 |
"go_cpu_classes_user_cpu_seconds_total", |
| 33 |
"go_gc_cycles_automatic_gc_cycles_total", |
| 34 |
"go_gc_cycles_forced_gc_cycles_total", |
| 35 |
"go_gc_cycles_total_gc_cycles_total", |
| 36 |
"go_gc_heap_allocs_by_size_bytes", |
| 37 |
"go_gc_heap_allocs_bytes_total", |
| 38 |
"go_gc_heap_allocs_objects_total", |
| 39 |
"go_gc_heap_frees_by_size_bytes", |
| 40 |
"go_gc_heap_frees_bytes_total", |
| 41 |
"go_gc_heap_frees_objects_total", |
| 42 |
"go_gc_heap_goal_bytes", |
| 43 |
"go_gc_heap_objects_objects", |
| 44 |
"go_gc_heap_tiny_allocs_objects_total", |
| 45 |
"go_gc_limiter_last_enabled_gc_cycle", |
| 46 |
"go_gc_pauses_seconds", |
| 47 |
"go_gc_stack_starting_size_bytes", |
| 48 |
"go_memory_classes_heap_free_bytes", |
| 49 |
"go_memory_classes_heap_objects_bytes", |
| 50 |
"go_memory_classes_heap_released_bytes", |
| 51 |
"go_memory_classes_heap_stacks_bytes", |
| 52 |
"go_memory_classes_heap_unused_bytes", |
| 53 |
"go_memory_classes_metadata_mcache_free_bytes", |
| 54 |
"go_memory_classes_metadata_mcache_inuse_bytes", |
| 55 |
"go_memory_classes_metadata_mspan_free_bytes", |
| 56 |
"go_memory_classes_metadata_mspan_inuse_bytes", |
| 57 |
"go_memory_classes_metadata_other_bytes", |
| 58 |
"go_memory_classes_os_stacks_bytes", |
| 59 |
"go_memory_classes_other_bytes", |
| 60 |
"go_memory_classes_profiling_buckets_bytes", |
| 61 |
"go_memory_classes_total_bytes", |
| 62 |
"go_sched_gomaxprocs_threads", |
| 63 |
"go_sched_goroutines_goroutines", |
| 64 |
"go_sched_latencies_seconds", |
| 65 |
"go_sync_mutex_wait_total_seconds_total", |
| 66 |
}) |
| 67 |
} |
| 68 |
|
| 69 |
func withGCMetrics() []string { |
| 70 |
return withBaseMetrics([]string{ |
| 71 |
"go_gc_cycles_automatic_gc_cycles_total", |
| 72 |
"go_gc_cycles_forced_gc_cycles_total", |
| 73 |
"go_gc_cycles_total_gc_cycles_total", |
| 74 |
"go_gc_heap_allocs_by_size_bytes", |
| 75 |
"go_gc_heap_allocs_bytes_total", |
| 76 |
"go_gc_heap_allocs_objects_total", |
| 77 |
"go_gc_heap_frees_by_size_bytes", |
| 78 |
"go_gc_heap_frees_bytes_total", |
| 79 |
"go_gc_heap_frees_objects_total", |
| 80 |
"go_gc_heap_goal_bytes", |
| 81 |
"go_gc_heap_objects_objects", |
| 82 |
"go_gc_heap_tiny_allocs_objects_total", |
| 83 |
"go_gc_limiter_last_enabled_gc_cycle", |
| 84 |
"go_gc_pauses_seconds", |
| 85 |
"go_gc_stack_starting_size_bytes", |
| 86 |
}) |
| 87 |
} |
| 88 |
|
| 89 |
func withMemoryMetrics() []string { |
| 90 |
return withBaseMetrics([]string{ |
| 91 |
"go_memory_classes_heap_free_bytes", |
| 92 |
"go_memory_classes_heap_objects_bytes", |
| 93 |
"go_memory_classes_heap_released_bytes", |
| 94 |
"go_memory_classes_heap_stacks_bytes", |
| 95 |
"go_memory_classes_heap_unused_bytes", |
| 96 |
"go_memory_classes_metadata_mcache_free_bytes", |
| 97 |
"go_memory_classes_metadata_mcache_inuse_bytes", |
| 98 |
"go_memory_classes_metadata_mspan_free_bytes", |
| 99 |
"go_memory_classes_metadata_mspan_inuse_bytes", |
| 100 |
"go_memory_classes_metadata_other_bytes", |
| 101 |
"go_memory_classes_os_stacks_bytes", |
| 102 |
"go_memory_classes_other_bytes", |
| 103 |
"go_memory_classes_profiling_buckets_bytes", |
| 104 |
"go_memory_classes_total_bytes", |
| 105 |
}) |
| 106 |
} |
| 107 |
|
| 108 |
func withSchedulerMetrics() []string { |
| 109 |
return withBaseMetrics([]string{ |
| 110 |
"go_sched_gomaxprocs_threads", |
| 111 |
"go_sched_goroutines_goroutines", |
| 112 |
"go_sched_latencies_seconds", |
| 113 |
}) |
| 114 |
} |
| 115 |
|
| 116 |
func withDebugMetrics() []string { |
| 117 |
return withBaseMetrics([]string{}) |
| 118 |
} |
| 119 |
|
| 120 |
var ( |
| 121 |
defaultRuntimeMetrics = []string{ |
| 122 |
"go_sched_gomaxprocs_threads", |
| 123 |
} |
| 124 |
onlyGCDefRuntimeMetrics = []string{} |
| 125 |
onlySchedDefRuntimeMetrics = []string{ |
| 126 |
"go_sched_gomaxprocs_threads", |
| 127 |
} |
| 128 |
) |