diff --git a/prometheus/collectors/gen_go_collector_set.go b/prometheus/collectors/gen_go_collector_set.go index 61e09bb..48b3ae5 100644 --- a/prometheus/collectors/gen_go_collector_set.go +++ b/prometheus/collectors/gen_go_collector_set.go @@ -135,18 +135,6 @@ func groupMetrics(metricsList []string) []metricGroup { } } - // Scheduler metrics is `sched` regex plus base metrics - // List of base metrics are taken from here: https://github.com/prometheus/client_golang/blob/26e3055e5133a9d64e8e5a07a7cf026875d5f55d/prometheus/go_collector.go#L208 - if group.Name == "withSchedulerMetrics" { - baseMatrices := []string{ - "go_gc_duration_seconds", - "go_goroutines", - "go_info", - "go_memstats_last_gc_time_seconds", - "go_threads", - } - matchedMetrics = append(matchedMetrics, baseMatrices...) - } sort.Strings(matchedMetrics) if len(matchedMetrics) > 0 { groupedMetrics = append(groupedMetrics, metricGroup{ @@ -173,9 +161,6 @@ var testFile = template.Must(template.New("testFile").Funcs(map[string]interface "nextVersion": func(version goVersion) string { return (version + goVersion(1)).String() }, - "needsBaseMetrics": func(groupName string) bool { - return groupName == "withAllMetrics" || groupName == "withGCMetrics" || groupName == "withMemoryMetrics" - }, }).Parse(`// Copyright 2022 The Prometheus Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -196,19 +181,11 @@ package collectors {{- range .Groups }} func {{ .Name }}() []string { - {{- if needsBaseMetrics .Name }} return withBaseMetrics([]string{ {{- range $metric := .Metrics }} {{ $metric | printf "%q" }}, {{- end }} }) - {{- else }} - return []string{ - {{- range $metric := .Metrics }} - {{ $metric | printf "%q" }}, - {{- end }} - } - {{- end }} } {{ end }} `)) diff --git a/prometheus/collectors/go_collector_go120_test.go b/prometheus/collectors/go_collector_go120_test.go index 3bdb4d5..d87ba5d 100644 --- a/prometheus/collectors/go_collector_go120_test.go +++ b/prometheus/collectors/go_collector_go120_test.go @@ -19,9 +19,6 @@ package collectors func withAllMetrics() []string { return withBaseMetrics([]string{ "go_cgo_go_to_c_calls_calls_total", - "go_gc_cycles_automatic_gc_cycles_total", - "go_gc_cycles_forced_gc_cycles_total", - "go_gc_cycles_total_gc_cycles_total", "go_cpu_classes_gc_mark_assist_cpu_seconds_total", "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", "go_cpu_classes_gc_mark_idle_cpu_seconds_total", @@ -33,6 +30,9 @@ func withAllMetrics() []string { "go_cpu_classes_scavenge_total_cpu_seconds_total", "go_cpu_classes_total_cpu_seconds_total", "go_cpu_classes_user_cpu_seconds_total", + "go_gc_cycles_automatic_gc_cycles_total", + "go_gc_cycles_forced_gc_cycles_total", + "go_gc_cycles_total_gc_cycles_total", "go_gc_heap_allocs_by_size_bytes", "go_gc_heap_allocs_bytes_total", "go_gc_heap_allocs_objects_total", @@ -106,14 +106,9 @@ func withMemoryMetrics() []string { } func withSchedulerMetrics() []string { - return []string{ - "go_gc_duration_seconds", - "go_goroutines", - "go_info", - "go_memstats_last_gc_time_seconds", + return withBaseMetrics([]string{ "go_sched_gomaxprocs_threads", "go_sched_goroutines_goroutines", "go_sched_latencies_seconds", - "go_threads", - } + }) } diff --git a/prometheus/collectors/go_collector_go121_test.go b/prometheus/collectors/go_collector_go121_test.go index 6facf67..683570c 100644 --- a/prometheus/collectors/go_collector_go121_test.go +++ b/prometheus/collectors/go_collector_go121_test.go @@ -138,20 +138,15 @@ func withMemoryMetrics() []string { } func withSchedulerMetrics() []string { - return []string{ - "go_gc_duration_seconds", - "go_goroutines", - "go_info", - "go_memstats_last_gc_time_seconds", + return withBaseMetrics([]string{ "go_sched_gomaxprocs_threads", "go_sched_goroutines_goroutines", "go_sched_latencies_seconds", - "go_threads", - } + }) } func withDebugMetrics() []string { - return []string{ + return withBaseMetrics([]string{ "go_godebug_non_default_behavior_execerrdot_events_total", "go_godebug_non_default_behavior_gocachehash_events_total", "go_godebug_non_default_behavior_gocachetest_events_total", @@ -170,5 +165,5 @@ func withDebugMetrics() []string { "go_godebug_non_default_behavior_x509sha1_events_total", "go_godebug_non_default_behavior_x509usefallbackroots_events_total", "go_godebug_non_default_behavior_zipinsecurepath_events_total", - } + }) } diff --git a/prometheus/collectors/go_collector_go122_test.go b/prometheus/collectors/go_collector_go122_test.go index 0b3c37a..a9cb069 100644 --- a/prometheus/collectors/go_collector_go122_test.go +++ b/prometheus/collectors/go_collector_go122_test.go @@ -149,11 +149,7 @@ func withMemoryMetrics() []string { } func withSchedulerMetrics() []string { - return []string{ - "go_gc_duration_seconds", - "go_goroutines", - "go_info", - "go_memstats_last_gc_time_seconds", + return withBaseMetrics([]string{ "go_sched_gomaxprocs_threads", "go_sched_goroutines_goroutines", "go_sched_latencies_seconds", @@ -161,12 +157,11 @@ func withSchedulerMetrics() []string { "go_sched_pauses_stopping_other_seconds", "go_sched_pauses_total_gc_seconds", "go_sched_pauses_total_other_seconds", - "go_threads", - } + }) } func withDebugMetrics() []string { - return []string{ + return withBaseMetrics([]string{ "go_godebug_non_default_behavior_execerrdot_events_total", "go_godebug_non_default_behavior_gocachehash_events_total", "go_godebug_non_default_behavior_gocachetest_events_total", @@ -192,5 +187,5 @@ func withDebugMetrics() []string { "go_godebug_non_default_behavior_x509usefallbackroots_events_total", "go_godebug_non_default_behavior_x509usepolicies_events_total", "go_godebug_non_default_behavior_zipinsecurepath_events_total", - } + }) }