Skip to content

Commit 02c6079

Browse files
ArthurSensgithub-actions[bot]
authored andcommitted
Update Go Collector metrics for new Go version
1 parent dbf72fc commit 02c6079

5 files changed

+314
-55
lines changed

Diff for: prometheus/collectors/go_collector_go121_test.go

-27
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package collectors
1818

19-
import "sort"
20-
2119
func withAllMetrics() []string {
2220
return withBaseMetrics([]string{
2321
"go_cgo_go_to_c_calls_calls_total",
@@ -171,28 +169,3 @@ func withDebugMetrics() []string {
171169
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
172170
})
173171
}
174-
175-
var defaultRuntimeMetrics = []string{
176-
"go_gc_gogc_percent",
177-
"go_gc_gomemlimit_bytes",
178-
"go_sched_gomaxprocs_threads",
179-
}
180-
181-
func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string {
182-
if withoutGC && withoutSched {
183-
// If both flags are true, return the metricNames as is.
184-
return metricNames
185-
} else if withoutGC && !withoutSched {
186-
// If only withoutGC is true, include "go_sched_gomaxprocs_threads" only.
187-
metricNames = append(metricNames, []string{"go_sched_gomaxprocs_threads"}...)
188-
} else if withoutSched && !withoutGC {
189-
// If only withoutSched is true, exclude "go_sched_gomaxprocs_threads".
190-
metricNames = append(metricNames, []string{"go_gc_gogc_percent", "go_gc_gomemlimit_bytes"}...)
191-
} else {
192-
// If neither flag is true, use the default metrics.
193-
metricNames = append(metricNames, defaultRuntimeMetrics...)
194-
}
195-
// sorting is required
196-
sort.Strings(metricNames)
197-
return metricNames
198-
}

Diff for: prometheus/collectors/go_collector_go122_test.go

-27
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package collectors
1818

19-
import "sort"
20-
2119
func withAllMetrics() []string {
2220
return withBaseMetrics([]string{
2321
"go_cgo_go_to_c_calls_calls_total",
@@ -193,28 +191,3 @@ func withDebugMetrics() []string {
193191
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
194192
})
195193
}
196-
197-
var defaultRuntimeMetrics = []string{
198-
"go_gc_gogc_percent",
199-
"go_gc_gomemlimit_bytes",
200-
"go_sched_gomaxprocs_threads",
201-
}
202-
203-
func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string {
204-
if withoutGC && withoutSched {
205-
// If both flags are true, return the metricNames as is.
206-
return metricNames
207-
} else if withoutGC && !withoutSched {
208-
// If only withoutGC is true, include "go_sched_gomaxprocs_threads" only.
209-
metricNames = append(metricNames, []string{"go_sched_gomaxprocs_threads"}...)
210-
} else if withoutSched && !withoutGC {
211-
// If only withoutSched is true, exclude "go_sched_gomaxprocs_threads".
212-
metricNames = append(metricNames, []string{"go_gc_gogc_percent", "go_gc_gomemlimit_bytes"}...)
213-
} else {
214-
// If neither flag is true, use the default metrics.
215-
metricNames = append(metricNames, defaultRuntimeMetrics...)
216-
}
217-
// sorting is required
218-
sort.Strings(metricNames)
219-
return metricNames
220-
}

Diff for: prometheus/collectors/go_collector_go123_test.go

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
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.23 && !go1.24
15+
// +build go1.23,!go1.24
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_gogc_percent",
37+
"go_gc_gomemlimit_bytes",
38+
"go_gc_heap_allocs_by_size_bytes",
39+
"go_gc_heap_allocs_bytes_total",
40+
"go_gc_heap_allocs_objects_total",
41+
"go_gc_heap_frees_by_size_bytes",
42+
"go_gc_heap_frees_bytes_total",
43+
"go_gc_heap_frees_objects_total",
44+
"go_gc_heap_goal_bytes",
45+
"go_gc_heap_live_bytes",
46+
"go_gc_heap_objects_objects",
47+
"go_gc_heap_tiny_allocs_objects_total",
48+
"go_gc_limiter_last_enabled_gc_cycle",
49+
"go_gc_pauses_seconds",
50+
"go_gc_scan_globals_bytes",
51+
"go_gc_scan_heap_bytes",
52+
"go_gc_scan_stack_bytes",
53+
"go_gc_scan_total_bytes",
54+
"go_gc_stack_starting_size_bytes",
55+
"go_godebug_non_default_behavior_asynctimerchan_events_total",
56+
"go_godebug_non_default_behavior_execerrdot_events_total",
57+
"go_godebug_non_default_behavior_gocachehash_events_total",
58+
"go_godebug_non_default_behavior_gocachetest_events_total",
59+
"go_godebug_non_default_behavior_gocacheverify_events_total",
60+
"go_godebug_non_default_behavior_gotypesalias_events_total",
61+
"go_godebug_non_default_behavior_http2client_events_total",
62+
"go_godebug_non_default_behavior_http2server_events_total",
63+
"go_godebug_non_default_behavior_httplaxcontentlength_events_total",
64+
"go_godebug_non_default_behavior_httpmuxgo121_events_total",
65+
"go_godebug_non_default_behavior_httpservecontentkeepheaders_events_total",
66+
"go_godebug_non_default_behavior_installgoroot_events_total",
67+
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
68+
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
69+
"go_godebug_non_default_behavior_multipathtcp_events_total",
70+
"go_godebug_non_default_behavior_netedns0_events_total",
71+
"go_godebug_non_default_behavior_panicnil_events_total",
72+
"go_godebug_non_default_behavior_randautoseed_events_total",
73+
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
74+
"go_godebug_non_default_behavior_tls10server_events_total",
75+
"go_godebug_non_default_behavior_tls3des_events_total",
76+
"go_godebug_non_default_behavior_tlsmaxrsasize_events_total",
77+
"go_godebug_non_default_behavior_tlsrsakex_events_total",
78+
"go_godebug_non_default_behavior_tlsunsafeekm_events_total",
79+
"go_godebug_non_default_behavior_winreadlinkvolume_events_total",
80+
"go_godebug_non_default_behavior_winsymlink_events_total",
81+
"go_godebug_non_default_behavior_x509keypairleaf_events_total",
82+
"go_godebug_non_default_behavior_x509negativeserial_events_total",
83+
"go_godebug_non_default_behavior_x509sha1_events_total",
84+
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
85+
"go_godebug_non_default_behavior_x509usepolicies_events_total",
86+
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
87+
"go_memory_classes_heap_free_bytes",
88+
"go_memory_classes_heap_objects_bytes",
89+
"go_memory_classes_heap_released_bytes",
90+
"go_memory_classes_heap_stacks_bytes",
91+
"go_memory_classes_heap_unused_bytes",
92+
"go_memory_classes_metadata_mcache_free_bytes",
93+
"go_memory_classes_metadata_mcache_inuse_bytes",
94+
"go_memory_classes_metadata_mspan_free_bytes",
95+
"go_memory_classes_metadata_mspan_inuse_bytes",
96+
"go_memory_classes_metadata_other_bytes",
97+
"go_memory_classes_os_stacks_bytes",
98+
"go_memory_classes_other_bytes",
99+
"go_memory_classes_profiling_buckets_bytes",
100+
"go_memory_classes_total_bytes",
101+
"go_sched_gomaxprocs_threads",
102+
"go_sched_goroutines_goroutines",
103+
"go_sched_latencies_seconds",
104+
"go_sched_pauses_stopping_gc_seconds",
105+
"go_sched_pauses_stopping_other_seconds",
106+
"go_sched_pauses_total_gc_seconds",
107+
"go_sched_pauses_total_other_seconds",
108+
"go_sync_mutex_wait_total_seconds_total",
109+
})
110+
}
111+
112+
func withGCMetrics() []string {
113+
return withBaseMetrics([]string{
114+
"go_gc_cycles_automatic_gc_cycles_total",
115+
"go_gc_cycles_forced_gc_cycles_total",
116+
"go_gc_cycles_total_gc_cycles_total",
117+
"go_gc_gogc_percent",
118+
"go_gc_gomemlimit_bytes",
119+
"go_gc_heap_allocs_by_size_bytes",
120+
"go_gc_heap_allocs_bytes_total",
121+
"go_gc_heap_allocs_objects_total",
122+
"go_gc_heap_frees_by_size_bytes",
123+
"go_gc_heap_frees_bytes_total",
124+
"go_gc_heap_frees_objects_total",
125+
"go_gc_heap_goal_bytes",
126+
"go_gc_heap_live_bytes",
127+
"go_gc_heap_objects_objects",
128+
"go_gc_heap_tiny_allocs_objects_total",
129+
"go_gc_limiter_last_enabled_gc_cycle",
130+
"go_gc_pauses_seconds",
131+
"go_gc_scan_globals_bytes",
132+
"go_gc_scan_heap_bytes",
133+
"go_gc_scan_stack_bytes",
134+
"go_gc_scan_total_bytes",
135+
"go_gc_stack_starting_size_bytes",
136+
})
137+
}
138+
139+
func withMemoryMetrics() []string {
140+
return withBaseMetrics([]string{
141+
"go_memory_classes_heap_free_bytes",
142+
"go_memory_classes_heap_objects_bytes",
143+
"go_memory_classes_heap_released_bytes",
144+
"go_memory_classes_heap_stacks_bytes",
145+
"go_memory_classes_heap_unused_bytes",
146+
"go_memory_classes_metadata_mcache_free_bytes",
147+
"go_memory_classes_metadata_mcache_inuse_bytes",
148+
"go_memory_classes_metadata_mspan_free_bytes",
149+
"go_memory_classes_metadata_mspan_inuse_bytes",
150+
"go_memory_classes_metadata_other_bytes",
151+
"go_memory_classes_os_stacks_bytes",
152+
"go_memory_classes_other_bytes",
153+
"go_memory_classes_profiling_buckets_bytes",
154+
"go_memory_classes_total_bytes",
155+
})
156+
}
157+
158+
func withSchedulerMetrics() []string {
159+
return withBaseMetrics([]string{
160+
"go_sched_gomaxprocs_threads",
161+
"go_sched_goroutines_goroutines",
162+
"go_sched_latencies_seconds",
163+
"go_sched_pauses_stopping_gc_seconds",
164+
"go_sched_pauses_stopping_other_seconds",
165+
"go_sched_pauses_total_gc_seconds",
166+
"go_sched_pauses_total_other_seconds",
167+
})
168+
}
169+
170+
func withDebugMetrics() []string {
171+
return withBaseMetrics([]string{
172+
"go_godebug_non_default_behavior_asynctimerchan_events_total",
173+
"go_godebug_non_default_behavior_execerrdot_events_total",
174+
"go_godebug_non_default_behavior_gocachehash_events_total",
175+
"go_godebug_non_default_behavior_gocachetest_events_total",
176+
"go_godebug_non_default_behavior_gocacheverify_events_total",
177+
"go_godebug_non_default_behavior_gotypesalias_events_total",
178+
"go_godebug_non_default_behavior_http2client_events_total",
179+
"go_godebug_non_default_behavior_http2server_events_total",
180+
"go_godebug_non_default_behavior_httplaxcontentlength_events_total",
181+
"go_godebug_non_default_behavior_httpmuxgo121_events_total",
182+
"go_godebug_non_default_behavior_httpservecontentkeepheaders_events_total",
183+
"go_godebug_non_default_behavior_installgoroot_events_total",
184+
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
185+
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
186+
"go_godebug_non_default_behavior_multipathtcp_events_total",
187+
"go_godebug_non_default_behavior_netedns0_events_total",
188+
"go_godebug_non_default_behavior_panicnil_events_total",
189+
"go_godebug_non_default_behavior_randautoseed_events_total",
190+
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
191+
"go_godebug_non_default_behavior_tls10server_events_total",
192+
"go_godebug_non_default_behavior_tls3des_events_total",
193+
"go_godebug_non_default_behavior_tlsmaxrsasize_events_total",
194+
"go_godebug_non_default_behavior_tlsrsakex_events_total",
195+
"go_godebug_non_default_behavior_tlsunsafeekm_events_total",
196+
"go_godebug_non_default_behavior_winreadlinkvolume_events_total",
197+
"go_godebug_non_default_behavior_winsymlink_events_total",
198+
"go_godebug_non_default_behavior_x509keypairleaf_events_total",
199+
"go_godebug_non_default_behavior_x509negativeserial_events_total",
200+
"go_godebug_non_default_behavior_x509sha1_events_total",
201+
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
202+
"go_godebug_non_default_behavior_x509usepolicies_events_total",
203+
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
204+
})
205+
}

0 commit comments

Comments
 (0)