chore: Refactor how base metrics are added to Sched metrics
Signed-off-by: Arthur Silva Sens <arthur.sens@coralogix.com>
This commit is contained in:
parent
93cf5d4f5f
commit
ec6ba13cc3
|
@ -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)
|
sort.Strings(matchedMetrics)
|
||||||
if len(matchedMetrics) > 0 {
|
if len(matchedMetrics) > 0 {
|
||||||
groupedMetrics = append(groupedMetrics, metricGroup{
|
groupedMetrics = append(groupedMetrics, metricGroup{
|
||||||
|
@ -173,9 +161,6 @@ var testFile = template.Must(template.New("testFile").Funcs(map[string]interface
|
||||||
"nextVersion": func(version goVersion) string {
|
"nextVersion": func(version goVersion) string {
|
||||||
return (version + goVersion(1)).String()
|
return (version + goVersion(1)).String()
|
||||||
},
|
},
|
||||||
"needsBaseMetrics": func(groupName string) bool {
|
|
||||||
return groupName == "withAllMetrics" || groupName == "withGCMetrics" || groupName == "withMemoryMetrics"
|
|
||||||
},
|
|
||||||
}).Parse(`// Copyright 2022 The Prometheus Authors
|
}).Parse(`// Copyright 2022 The Prometheus Authors
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
|
@ -196,19 +181,11 @@ package collectors
|
||||||
|
|
||||||
{{- range .Groups }}
|
{{- range .Groups }}
|
||||||
func {{ .Name }}() []string {
|
func {{ .Name }}() []string {
|
||||||
{{- if needsBaseMetrics .Name }}
|
|
||||||
return withBaseMetrics([]string{
|
return withBaseMetrics([]string{
|
||||||
{{- range $metric := .Metrics }}
|
{{- range $metric := .Metrics }}
|
||||||
{{ $metric | printf "%q" }},
|
{{ $metric | printf "%q" }},
|
||||||
{{- end }}
|
{{- end }}
|
||||||
})
|
})
|
||||||
{{- else }}
|
|
||||||
return []string{
|
|
||||||
{{- range $metric := .Metrics }}
|
|
||||||
{{ $metric | printf "%q" }},
|
|
||||||
{{- end }}
|
|
||||||
}
|
|
||||||
{{- end }}
|
|
||||||
}
|
}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
`))
|
`))
|
||||||
|
|
|
@ -19,9 +19,6 @@ package collectors
|
||||||
func withAllMetrics() []string {
|
func withAllMetrics() []string {
|
||||||
return withBaseMetrics([]string{
|
return withBaseMetrics([]string{
|
||||||
"go_cgo_go_to_c_calls_calls_total",
|
"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_assist_cpu_seconds_total",
|
||||||
"go_cpu_classes_gc_mark_dedicated_cpu_seconds_total",
|
"go_cpu_classes_gc_mark_dedicated_cpu_seconds_total",
|
||||||
"go_cpu_classes_gc_mark_idle_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_scavenge_total_cpu_seconds_total",
|
||||||
"go_cpu_classes_total_cpu_seconds_total",
|
"go_cpu_classes_total_cpu_seconds_total",
|
||||||
"go_cpu_classes_user_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_by_size_bytes",
|
||||||
"go_gc_heap_allocs_bytes_total",
|
"go_gc_heap_allocs_bytes_total",
|
||||||
"go_gc_heap_allocs_objects_total",
|
"go_gc_heap_allocs_objects_total",
|
||||||
|
@ -106,14 +106,9 @@ func withMemoryMetrics() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func withSchedulerMetrics() []string {
|
func withSchedulerMetrics() []string {
|
||||||
return []string{
|
return withBaseMetrics([]string{
|
||||||
"go_gc_duration_seconds",
|
|
||||||
"go_goroutines",
|
|
||||||
"go_info",
|
|
||||||
"go_memstats_last_gc_time_seconds",
|
|
||||||
"go_sched_gomaxprocs_threads",
|
"go_sched_gomaxprocs_threads",
|
||||||
"go_sched_goroutines_goroutines",
|
"go_sched_goroutines_goroutines",
|
||||||
"go_sched_latencies_seconds",
|
"go_sched_latencies_seconds",
|
||||||
"go_threads",
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,20 +138,15 @@ func withMemoryMetrics() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func withSchedulerMetrics() []string {
|
func withSchedulerMetrics() []string {
|
||||||
return []string{
|
return withBaseMetrics([]string{
|
||||||
"go_gc_duration_seconds",
|
|
||||||
"go_goroutines",
|
|
||||||
"go_info",
|
|
||||||
"go_memstats_last_gc_time_seconds",
|
|
||||||
"go_sched_gomaxprocs_threads",
|
"go_sched_gomaxprocs_threads",
|
||||||
"go_sched_goroutines_goroutines",
|
"go_sched_goroutines_goroutines",
|
||||||
"go_sched_latencies_seconds",
|
"go_sched_latencies_seconds",
|
||||||
"go_threads",
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func withDebugMetrics() []string {
|
func withDebugMetrics() []string {
|
||||||
return []string{
|
return withBaseMetrics([]string{
|
||||||
"go_godebug_non_default_behavior_execerrdot_events_total",
|
"go_godebug_non_default_behavior_execerrdot_events_total",
|
||||||
"go_godebug_non_default_behavior_gocachehash_events_total",
|
"go_godebug_non_default_behavior_gocachehash_events_total",
|
||||||
"go_godebug_non_default_behavior_gocachetest_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_x509sha1_events_total",
|
||||||
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
|
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
|
||||||
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
|
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,7 @@ func withMemoryMetrics() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func withSchedulerMetrics() []string {
|
func withSchedulerMetrics() []string {
|
||||||
return []string{
|
return withBaseMetrics([]string{
|
||||||
"go_gc_duration_seconds",
|
|
||||||
"go_goroutines",
|
|
||||||
"go_info",
|
|
||||||
"go_memstats_last_gc_time_seconds",
|
|
||||||
"go_sched_gomaxprocs_threads",
|
"go_sched_gomaxprocs_threads",
|
||||||
"go_sched_goroutines_goroutines",
|
"go_sched_goroutines_goroutines",
|
||||||
"go_sched_latencies_seconds",
|
"go_sched_latencies_seconds",
|
||||||
|
@ -161,12 +157,11 @@ func withSchedulerMetrics() []string {
|
||||||
"go_sched_pauses_stopping_other_seconds",
|
"go_sched_pauses_stopping_other_seconds",
|
||||||
"go_sched_pauses_total_gc_seconds",
|
"go_sched_pauses_total_gc_seconds",
|
||||||
"go_sched_pauses_total_other_seconds",
|
"go_sched_pauses_total_other_seconds",
|
||||||
"go_threads",
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func withDebugMetrics() []string {
|
func withDebugMetrics() []string {
|
||||||
return []string{
|
return withBaseMetrics([]string{
|
||||||
"go_godebug_non_default_behavior_execerrdot_events_total",
|
"go_godebug_non_default_behavior_execerrdot_events_total",
|
||||||
"go_godebug_non_default_behavior_gocachehash_events_total",
|
"go_godebug_non_default_behavior_gocachehash_events_total",
|
||||||
"go_godebug_non_default_behavior_gocachetest_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_x509usefallbackroots_events_total",
|
||||||
"go_godebug_non_default_behavior_x509usepolicies_events_total",
|
"go_godebug_non_default_behavior_x509usepolicies_events_total",
|
||||||
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
|
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue