From 3ad272204b3a9bf4c182d3baba3aac45436b87d1 Mon Sep 17 00:00:00 2001 From: Arianna Vespri <36129782+vesari@users.noreply.github.com> Date: Fri, 9 Aug 2024 21:27:25 +0200 Subject: [PATCH] Add default Go runtime metrics for /gc/gogc:percent, /gc/gomemlimit:bytes, /sched/gomaxprocs:threads (#1559) * Add go_gomaxprocs, go_gogc_percent and go_gomemlimit to the default Go runtime metrics Signed-off-by: Arianna Vespri * Move newly added metrics out of base metrics and into goCollector Signed-off-by: Arianna Vespri * Rethink struct for newly added metrics, adapt and add tests Signed-off-by: Arianna Vespri * Simplify new metrics reading Signed-off-by: Arianna Vespri * Correct loop, add debugging lines Signed-off-by: Arianna Vespri * Make goRuntimeEnvVarsMetrics function Go version dependent Signed-off-by: Arianna Vespri * Fix go mod Signed-off-by: Arianna Vespri * Remove debuggin line Signed-off-by: Arianna Vespri * Move default runtime metrics into the runtime metrics flow, change tests accordingly Signed-off-by: Arianna Vespri * Go version expected default runtime metrics map for tests Signed-off-by: Arianna Vespri * 1.21 update. Signed-off-by: bwplotka * Addressed comments on Arianna's PR. Signed-off-by: bwplotka * Use default GoCollector func in test Signed-off-by: Arianna Vespri --------- Signed-off-by: Arianna Vespri Signed-off-by: bwplotka Co-authored-by: bwplotka --- .../collectors/go_collector_go117_test.go | 6 + .../collectors/go_collector_go119_test.go | 17 ++ .../collectors/go_collector_go120_test.go | 17 ++ .../collectors/go_collector_go121_test.go | 27 +++ .../collectors/go_collector_go122_test.go | 27 +++ .../collectors/go_collector_latest_test.go | 28 ++- prometheus/gen_go_collector_metrics_set.go | 42 ++++- prometheus/go_collector_latest.go | 8 +- prometheus/go_collector_latest_test.go | 12 +- prometheus/go_collector_metrics_go120_test.go | 100 +++++----- prometheus/go_collector_metrics_go121_test.go | 154 +++++++-------- prometheus/go_collector_metrics_go122_test.go | 176 +++++++++--------- prometheus/internal/go_collector_options.go | 2 + 13 files changed, 389 insertions(+), 227 deletions(-) diff --git a/prometheus/collectors/go_collector_go117_test.go b/prometheus/collectors/go_collector_go117_test.go index 760ad046b..f378d4097 100644 --- a/prometheus/collectors/go_collector_go117_test.go +++ b/prometheus/collectors/go_collector_go117_test.go @@ -102,3 +102,9 @@ func withSchedulerMetrics() []string { func withDebugMetrics() []string { return withBaseMetrics([]string{}) } + +var defaultRuntimeMetrics = []string{} + +func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string { + return metricNames +} diff --git a/prometheus/collectors/go_collector_go119_test.go b/prometheus/collectors/go_collector_go119_test.go index 1ef9a4cf0..4febad2ce 100644 --- a/prometheus/collectors/go_collector_go119_test.go +++ b/prometheus/collectors/go_collector_go119_test.go @@ -16,6 +16,8 @@ package collectors +import "sort" + func withAllMetrics() []string { return withBaseMetrics([]string{ "go_cgo_go_to_c_calls_calls_total", @@ -109,3 +111,18 @@ func withSchedulerMetrics() []string { func withDebugMetrics() []string { return withBaseMetrics([]string{}) } + +var defaultRuntimeMetrics = []string{ + "go_sched_gomaxprocs_threads", +} + +func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string { + // If withoutSched is true, exclude "go_sched_gomaxprocs_threads". + if withoutSched { + return metricNames + } + metricNames = append(metricNames, defaultRuntimeMetrics...) + // sorting is required + sort.Strings(metricNames) + return metricNames +} diff --git a/prometheus/collectors/go_collector_go120_test.go b/prometheus/collectors/go_collector_go120_test.go index 723cbf826..968a016ab 100644 --- a/prometheus/collectors/go_collector_go120_test.go +++ b/prometheus/collectors/go_collector_go120_test.go @@ -16,6 +16,8 @@ package collectors +import "sort" + func withAllMetrics() []string { return withBaseMetrics([]string{ "go_cgo_go_to_c_calls_calls_total", @@ -116,3 +118,18 @@ func withSchedulerMetrics() []string { func withDebugMetrics() []string { return withBaseMetrics([]string{}) } + +var defaultRuntimeMetrics = []string{ + "go_sched_gomaxprocs_threads", +} + +func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string { + // If withoutSched is true, exclude "go_sched_gomaxprocs_threads". + if withoutSched { + return metricNames + } + metricNames = append(metricNames, defaultRuntimeMetrics...) + // sorting is required + sort.Strings(metricNames) + return metricNames +} diff --git a/prometheus/collectors/go_collector_go121_test.go b/prometheus/collectors/go_collector_go121_test.go index b105f7107..f9cc318cc 100644 --- a/prometheus/collectors/go_collector_go121_test.go +++ b/prometheus/collectors/go_collector_go121_test.go @@ -16,6 +16,8 @@ package collectors +import "sort" + func withAllMetrics() []string { return withBaseMetrics([]string{ "go_cgo_go_to_c_calls_calls_total", @@ -169,3 +171,28 @@ func withDebugMetrics() []string { "go_godebug_non_default_behavior_zipinsecurepath_events_total", }) } + +var defaultRuntimeMetrics = []string{ + "go_gc_gogc_percent", + "go_gc_gomemlimit_bytes", + "go_sched_gomaxprocs_threads", +} + +func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string { + if withoutGC && withoutSched { + // If both flags are true, return the metricNames as is. + return metricNames + } else if withoutGC && !withoutSched { + // If only withoutGC is true, include "go_sched_gomaxprocs_threads" only. + metricNames = append(metricNames, []string{"go_sched_gomaxprocs_threads"}...) + } else if withoutSched && !withoutGC { + // If only withoutSched is true, exclude "go_sched_gomaxprocs_threads". + metricNames = append(metricNames, []string{"go_gc_gogc_percent", "go_gc_gomemlimit_bytes"}...) + } else { + // If neither flag is true, use the default metrics. + metricNames = append(metricNames, defaultRuntimeMetrics...) + } + // sorting is required + sort.Strings(metricNames) + return metricNames +} diff --git a/prometheus/collectors/go_collector_go122_test.go b/prometheus/collectors/go_collector_go122_test.go index 0c863f1ee..2413c2750 100644 --- a/prometheus/collectors/go_collector_go122_test.go +++ b/prometheus/collectors/go_collector_go122_test.go @@ -16,6 +16,8 @@ package collectors +import "sort" + func withAllMetrics() []string { return withBaseMetrics([]string{ "go_cgo_go_to_c_calls_calls_total", @@ -191,3 +193,28 @@ func withDebugMetrics() []string { "go_godebug_non_default_behavior_zipinsecurepath_events_total", }) } + +var defaultRuntimeMetrics = []string{ + "go_gc_gogc_percent", + "go_gc_gomemlimit_bytes", + "go_sched_gomaxprocs_threads", +} + +func withDefaultRuntimeMetrics(metricNames []string, withoutGC, withoutSched bool) []string { + if withoutGC && withoutSched { + // If both flags are true, return the metricNames as is. + return metricNames + } else if withoutGC && !withoutSched { + // If only withoutGC is true, include "go_sched_gomaxprocs_threads" only. + metricNames = append(metricNames, []string{"go_sched_gomaxprocs_threads"}...) + } else if withoutSched && !withoutGC { + // If only withoutSched is true, exclude "go_sched_gomaxprocs_threads". + metricNames = append(metricNames, []string{"go_gc_gogc_percent", "go_gc_gomemlimit_bytes"}...) + } else { + // If neither flag is true, use the default metrics. + metricNames = append(metricNames, defaultRuntimeMetrics...) + } + // sorting is required + sort.Strings(metricNames) + return metricNames +} diff --git a/prometheus/collectors/go_collector_latest_test.go b/prometheus/collectors/go_collector_latest_test.go index 11331ed87..a7e7e1071 100644 --- a/prometheus/collectors/go_collector_latest_test.go +++ b/prometheus/collectors/go_collector_latest_test.go @@ -93,7 +93,9 @@ func TestWithGoCollectorDefault(t *testing.T) { got = append(got, r.GetName()) } - if diff := cmp.Diff(got, withBaseMetrics(memstatMetrics)); diff != "" { + expected := append(withBaseMetrics(memstatMetrics), defaultRuntimeMetrics...) + sort.Strings(expected) + if diff := cmp.Diff(got, expected); diff != "" { t.Errorf("[IMPORTANT, those are default metrics, can't change in 1.x] missmatch (-want +got):\n%s", diff) } } @@ -113,7 +115,7 @@ func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) { got = append(got, r.GetName()) } - if diff := cmp.Diff(got, baseMetrics); diff != "" { + if diff := cmp.Diff(got, withBaseMetrics(defaultRuntimeMetrics)); diff != "" { t.Errorf("missmatch (-want +got):\n%s", diff) } } @@ -127,7 +129,7 @@ func TestGoCollectorAllowList(t *testing.T) { { name: "Without any rules", rules: nil, - expected: baseMetrics, + expected: withBaseMetrics(defaultRuntimeMetrics), }, { name: "allow all", @@ -137,22 +139,22 @@ func TestGoCollectorAllowList(t *testing.T) { { name: "allow GC", rules: []GoRuntimeMetricsRule{MetricsGC}, - expected: withGCMetrics(), + expected: withDefaultRuntimeMetrics(withGCMetrics(), true, false), }, { name: "allow Memory", rules: []GoRuntimeMetricsRule{MetricsMemory}, - expected: withMemoryMetrics(), + expected: withDefaultRuntimeMetrics(withMemoryMetrics(), false, false), }, { name: "allow Scheduler", rules: []GoRuntimeMetricsRule{MetricsScheduler}, - expected: withSchedulerMetrics(), + expected: withDefaultRuntimeMetrics(withSchedulerMetrics(), false, true), }, { name: "allow debug", rules: []GoRuntimeMetricsRule{MetricsDebug}, - expected: withDebugMetrics(), + expected: withDefaultRuntimeMetrics(withDebugMetrics(), false, false), }, } { t.Run(test.name, func(t *testing.T) { @@ -193,7 +195,7 @@ func TestGoCollectorDenyList(t *testing.T) { { name: "Without any matchers", matchers: nil, - expected: baseMetrics, + expected: withBaseMetrics(defaultRuntimeMetrics), }, { name: "deny all", @@ -206,6 +208,14 @@ func TestGoCollectorDenyList(t *testing.T) { regexp.MustCompile("^/gc/.*"), regexp.MustCompile("^/sched/latencies:.*"), }, + expected: withDefaultRuntimeMetrics(baseMetrics, true, false), + }, + { + name: "deny gc and scheduler", + matchers: []*regexp.Regexp{ + regexp.MustCompile("^/gc/.*"), + regexp.MustCompile("^/sched/.*"), + }, expected: baseMetrics, }, } { @@ -235,7 +245,7 @@ func TestGoCollectorDenyList(t *testing.T) { func ExampleGoCollector() { reg := prometheus.NewRegistry() - // Register the GoCollector with the default options. Only the base metrics and memstats are enabled. + // Register the GoCollector with the default options. Only the base metrics, default runtime metrics and memstats are enabled. reg.MustRegister(NewGoCollector()) http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{})) diff --git a/prometheus/gen_go_collector_metrics_set.go b/prometheus/gen_go_collector_metrics_set.go index 2622b71e4..f1db3d8d1 100644 --- a/prometheus/gen_go_collector_metrics_set.go +++ b/prometheus/gen_go_collector_metrics_set.go @@ -63,16 +63,29 @@ func main() { v := goVersion(gv.Segments()[1]) log.Printf("generating metrics for Go version %q", v) + allDesc := metrics.All() + + // Find default metrics. + var defaultDesc []metrics.Description + for _, d := range allDesc { + if !internal.GoCollectorDefaultRuntimeMetrics.MatchString(d.Name) { + continue + } + defaultDesc = append(defaultDesc, d) + } + // Generate code. var buf bytes.Buffer err = testFile.Execute(&buf, struct { - Descriptions []metrics.Description - GoVersion goVersion - Cardinality int + AllDescriptions []metrics.Description + DefaultDescriptions []metrics.Description + GoVersion goVersion + Cardinality int }{ - Descriptions: metrics.All(), - GoVersion: v, - Cardinality: rmCardinality(), + AllDescriptions: allDesc, + DefaultDescriptions: defaultDesc, + GoVersion: v, + Cardinality: rmCardinality(), }) if err != nil { log.Fatalf("executing template: %v", err) @@ -167,14 +180,25 @@ var testFile = template.Must(template.New("testFile").Funcs(map[string]interface package prometheus -var expectedRuntimeMetrics = map[string]string{ -{{- range .Descriptions -}} +var ( + expectedRuntimeMetrics = map[string]string{ +{{- range .AllDescriptions -}} {{- $trans := rm2prom . -}} {{- if ne $trans "" }} {{.Name | printf "%q"}}: {{$trans | printf "%q"}}, {{- end -}} {{end}} -} + } + + expMetrics = map[string]string{ +{{- range .DefaultDescriptions -}} + {{- $trans := rm2prom . -}} + {{- if ne $trans "" }} + {{.Name | printf "%q"}}: {{$trans | printf "%q"}}, + {{- end -}} +{{end}} + } +) const expectedRuntimeMetricsCardinality = {{.Cardinality}} `)) diff --git a/prometheus/go_collector_latest.go b/prometheus/go_collector_latest.go index 2d8d9f64f..127d0b1ec 100644 --- a/prometheus/go_collector_latest.go +++ b/prometheus/go_collector_latest.go @@ -17,6 +17,7 @@ package prometheus import ( + "fmt" "math" "runtime" "runtime/metrics" @@ -153,7 +154,8 @@ func defaultGoCollectorOptions() internal.GoCollectorOptions { "/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes, }, RuntimeMetricRules: []internal.GoCollectorRule{ - //{Matcher: regexp.MustCompile("")}, + // Recommended metrics we want by default from runtime/metrics. + {Matcher: internal.GoCollectorDefaultRuntimeMetrics}, }, } } @@ -376,13 +378,13 @@ func unwrapScalarRMValue(v metrics.Value) float64 { // // This should never happen because we always populate our metric // set from the runtime/metrics package. - panic("unexpected unsupported metric") + panic("unexpected bad kind metric") default: // Unsupported metric kind. // // This should never happen because we check for this during initialization // and flag and filter metrics whose kinds we don't understand. - panic("unexpected unsupported metric kind") + panic(fmt.Sprintf("unexpected unsupported metric: %v", v.Kind())) } } diff --git a/prometheus/go_collector_latest_test.go b/prometheus/go_collector_latest_test.go index 551f49797..2fbe01bae 100644 --- a/prometheus/go_collector_latest_test.go +++ b/prometheus/go_collector_latest_test.go @@ -74,6 +74,13 @@ func addExpectedRuntimeMetrics(metrics map[string]struct{}) map[string]struct{} return metrics } +func addExpectedDefaultRuntimeMetrics(metrics map[string]struct{}) map[string]struct{} { + for _, e := range expMetrics { + metrics[e] = struct{}{} + } + return metrics +} + func TestGoCollector_ExposedMetrics(t *testing.T) { for _, tcase := range []struct { opts internal.GoCollectorOptions @@ -86,8 +93,9 @@ func TestGoCollector_ExposedMetrics(t *testing.T) { expectedFQNameSet: expectedBaseMetrics(), }, { - // Default, only MemStats. - expectedFQNameSet: addExpectedRuntimeMemStats(expectedBaseMetrics()), + // Default, only MemStats and default Runtime metrics. + opts: defaultGoCollectorOptions(), + expectedFQNameSet: addExpectedDefaultRuntimeMetrics(addExpectedRuntimeMemStats(expectedBaseMetrics())), }, { // Get all runtime/metrics without MemStats. diff --git a/prometheus/go_collector_metrics_go120_test.go b/prometheus/go_collector_metrics_go120_test.go index 60517c4c2..4c1ca38d3 100644 --- a/prometheus/go_collector_metrics_go120_test.go +++ b/prometheus/go_collector_metrics_go120_test.go @@ -6,52 +6,58 @@ package prometheus -var expectedRuntimeMetrics = map[string]string{ - "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", - "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", - "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", - "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", - "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", - "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", - "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", - "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", - "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", - "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", - "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", - "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", - "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", - "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", - "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", - "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", - "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", - "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", - "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", - "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", - "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", - "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", - "/gc/heap/objects:objects": "go_gc_heap_objects_objects", - "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", - "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", - "/gc/pauses:seconds": "go_gc_pauses_seconds", - "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", - "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", - "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", - "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", - "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", - "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", - "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", - "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", - "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", - "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", - "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", - "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", - "/memory/classes/other:bytes": "go_memory_classes_other_bytes", - "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", - "/memory/classes/total:bytes": "go_memory_classes_total_bytes", - "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", - "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", - "/sched/latencies:seconds": "go_sched_latencies_seconds", - "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", -} +var ( + expectedRuntimeMetrics = map[string]string{ + "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", + "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", + "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", + "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", + "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", + "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", + "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", + "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", + "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", + "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", + "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", + "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", + "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", + "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", + "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", + "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", + "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", + "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", + "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", + "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", + "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", + "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", + "/gc/heap/objects:objects": "go_gc_heap_objects_objects", + "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", + "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", + "/gc/pauses:seconds": "go_gc_pauses_seconds", + "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", + "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", + "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", + "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", + "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", + "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", + "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", + "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", + "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", + "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", + "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", + "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", + "/memory/classes/other:bytes": "go_memory_classes_other_bytes", + "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", + "/memory/classes/total:bytes": "go_memory_classes_total_bytes", + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", + "/sched/latencies:seconds": "go_sched_latencies_seconds", + "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", + } + + expMetrics = map[string]string{ + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + } +) const expectedRuntimeMetricsCardinality = 89 diff --git a/prometheus/go_collector_metrics_go121_test.go b/prometheus/go_collector_metrics_go121_test.go index 58a8f10d9..217b04fc7 100644 --- a/prometheus/go_collector_metrics_go121_test.go +++ b/prometheus/go_collector_metrics_go121_test.go @@ -6,78 +6,86 @@ package prometheus -var expectedRuntimeMetrics = map[string]string{ - "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", - "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", - "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", - "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", - "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", - "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", - "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", - "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", - "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", - "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", - "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", - "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", - "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", - "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", - "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", - "/gc/gogc:percent": "go_gc_gogc_percent", - "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", - "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", - "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", - "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", - "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", - "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", - "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", - "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", - "/gc/heap/live:bytes": "go_gc_heap_live_bytes", - "/gc/heap/objects:objects": "go_gc_heap_objects_objects", - "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", - "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", - "/gc/pauses:seconds": "go_gc_pauses_seconds", - "/gc/scan/globals:bytes": "go_gc_scan_globals_bytes", - "/gc/scan/heap:bytes": "go_gc_scan_heap_bytes", - "/gc/scan/stack:bytes": "go_gc_scan_stack_bytes", - "/gc/scan/total:bytes": "go_gc_scan_total_bytes", - "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", - "/godebug/non-default-behavior/execerrdot:events": "go_godebug_non_default_behavior_execerrdot_events_total", - "/godebug/non-default-behavior/gocachehash:events": "go_godebug_non_default_behavior_gocachehash_events_total", - "/godebug/non-default-behavior/gocachetest:events": "go_godebug_non_default_behavior_gocachetest_events_total", - "/godebug/non-default-behavior/gocacheverify:events": "go_godebug_non_default_behavior_gocacheverify_events_total", - "/godebug/non-default-behavior/http2client:events": "go_godebug_non_default_behavior_http2client_events_total", - "/godebug/non-default-behavior/http2server:events": "go_godebug_non_default_behavior_http2server_events_total", - "/godebug/non-default-behavior/installgoroot:events": "go_godebug_non_default_behavior_installgoroot_events_total", - "/godebug/non-default-behavior/jstmpllitinterp:events": "go_godebug_non_default_behavior_jstmpllitinterp_events_total", - "/godebug/non-default-behavior/multipartmaxheaders:events": "go_godebug_non_default_behavior_multipartmaxheaders_events_total", - "/godebug/non-default-behavior/multipartmaxparts:events": "go_godebug_non_default_behavior_multipartmaxparts_events_total", - "/godebug/non-default-behavior/multipathtcp:events": "go_godebug_non_default_behavior_multipathtcp_events_total", - "/godebug/non-default-behavior/netedns0:events": "go_godebug_non_default_behavior_netedns0_events_total", - "/godebug/non-default-behavior/panicnil:events": "go_godebug_non_default_behavior_panicnil_events_total", - "/godebug/non-default-behavior/randautoseed:events": "go_godebug_non_default_behavior_randautoseed_events_total", - "/godebug/non-default-behavior/tarinsecurepath:events": "go_godebug_non_default_behavior_tarinsecurepath_events_total", - "/godebug/non-default-behavior/tlsmaxrsasize:events": "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", - "/godebug/non-default-behavior/x509sha1:events": "go_godebug_non_default_behavior_x509sha1_events_total", - "/godebug/non-default-behavior/x509usefallbackroots:events": "go_godebug_non_default_behavior_x509usefallbackroots_events_total", - "/godebug/non-default-behavior/zipinsecurepath:events": "go_godebug_non_default_behavior_zipinsecurepath_events_total", - "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", - "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", - "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", - "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", - "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", - "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", - "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", - "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", - "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", - "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", - "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", - "/memory/classes/other:bytes": "go_memory_classes_other_bytes", - "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", - "/memory/classes/total:bytes": "go_memory_classes_total_bytes", - "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", - "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", - "/sched/latencies:seconds": "go_sched_latencies_seconds", - "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", -} +var ( + expectedRuntimeMetrics = map[string]string{ + "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", + "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", + "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", + "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", + "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", + "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", + "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", + "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", + "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", + "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", + "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", + "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", + "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", + "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", + "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", + "/gc/gogc:percent": "go_gc_gogc_percent", + "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", + "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", + "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", + "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", + "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", + "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", + "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", + "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", + "/gc/heap/live:bytes": "go_gc_heap_live_bytes", + "/gc/heap/objects:objects": "go_gc_heap_objects_objects", + "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", + "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", + "/gc/pauses:seconds": "go_gc_pauses_seconds", + "/gc/scan/globals:bytes": "go_gc_scan_globals_bytes", + "/gc/scan/heap:bytes": "go_gc_scan_heap_bytes", + "/gc/scan/stack:bytes": "go_gc_scan_stack_bytes", + "/gc/scan/total:bytes": "go_gc_scan_total_bytes", + "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", + "/godebug/non-default-behavior/execerrdot:events": "go_godebug_non_default_behavior_execerrdot_events_total", + "/godebug/non-default-behavior/gocachehash:events": "go_godebug_non_default_behavior_gocachehash_events_total", + "/godebug/non-default-behavior/gocachetest:events": "go_godebug_non_default_behavior_gocachetest_events_total", + "/godebug/non-default-behavior/gocacheverify:events": "go_godebug_non_default_behavior_gocacheverify_events_total", + "/godebug/non-default-behavior/http2client:events": "go_godebug_non_default_behavior_http2client_events_total", + "/godebug/non-default-behavior/http2server:events": "go_godebug_non_default_behavior_http2server_events_total", + "/godebug/non-default-behavior/installgoroot:events": "go_godebug_non_default_behavior_installgoroot_events_total", + "/godebug/non-default-behavior/jstmpllitinterp:events": "go_godebug_non_default_behavior_jstmpllitinterp_events_total", + "/godebug/non-default-behavior/multipartmaxheaders:events": "go_godebug_non_default_behavior_multipartmaxheaders_events_total", + "/godebug/non-default-behavior/multipartmaxparts:events": "go_godebug_non_default_behavior_multipartmaxparts_events_total", + "/godebug/non-default-behavior/multipathtcp:events": "go_godebug_non_default_behavior_multipathtcp_events_total", + "/godebug/non-default-behavior/netedns0:events": "go_godebug_non_default_behavior_netedns0_events_total", + "/godebug/non-default-behavior/panicnil:events": "go_godebug_non_default_behavior_panicnil_events_total", + "/godebug/non-default-behavior/randautoseed:events": "go_godebug_non_default_behavior_randautoseed_events_total", + "/godebug/non-default-behavior/tarinsecurepath:events": "go_godebug_non_default_behavior_tarinsecurepath_events_total", + "/godebug/non-default-behavior/tlsmaxrsasize:events": "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", + "/godebug/non-default-behavior/x509sha1:events": "go_godebug_non_default_behavior_x509sha1_events_total", + "/godebug/non-default-behavior/x509usefallbackroots:events": "go_godebug_non_default_behavior_x509usefallbackroots_events_total", + "/godebug/non-default-behavior/zipinsecurepath:events": "go_godebug_non_default_behavior_zipinsecurepath_events_total", + "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", + "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", + "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", + "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", + "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", + "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", + "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", + "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", + "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", + "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", + "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", + "/memory/classes/other:bytes": "go_memory_classes_other_bytes", + "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", + "/memory/classes/total:bytes": "go_memory_classes_total_bytes", + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", + "/sched/latencies:seconds": "go_sched_latencies_seconds", + "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", + } + + expMetrics = map[string]string{ + "/gc/gogc:percent": "go_gc_gogc_percent", + "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + } +) const expectedRuntimeMetricsCardinality = 115 diff --git a/prometheus/go_collector_metrics_go122_test.go b/prometheus/go_collector_metrics_go122_test.go index b40d93a60..6aa3a9f7e 100644 --- a/prometheus/go_collector_metrics_go122_test.go +++ b/prometheus/go_collector_metrics_go122_test.go @@ -6,89 +6,97 @@ package prometheus -var expectedRuntimeMetrics = map[string]string{ - "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", - "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", - "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", - "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", - "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", - "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", - "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", - "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", - "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", - "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", - "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", - "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", - "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", - "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", - "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", - "/gc/gogc:percent": "go_gc_gogc_percent", - "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", - "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", - "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", - "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", - "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", - "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", - "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", - "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", - "/gc/heap/live:bytes": "go_gc_heap_live_bytes", - "/gc/heap/objects:objects": "go_gc_heap_objects_objects", - "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", - "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", - "/gc/pauses:seconds": "go_gc_pauses_seconds", - "/gc/scan/globals:bytes": "go_gc_scan_globals_bytes", - "/gc/scan/heap:bytes": "go_gc_scan_heap_bytes", - "/gc/scan/stack:bytes": "go_gc_scan_stack_bytes", - "/gc/scan/total:bytes": "go_gc_scan_total_bytes", - "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", - "/godebug/non-default-behavior/execerrdot:events": "go_godebug_non_default_behavior_execerrdot_events_total", - "/godebug/non-default-behavior/gocachehash:events": "go_godebug_non_default_behavior_gocachehash_events_total", - "/godebug/non-default-behavior/gocachetest:events": "go_godebug_non_default_behavior_gocachetest_events_total", - "/godebug/non-default-behavior/gocacheverify:events": "go_godebug_non_default_behavior_gocacheverify_events_total", - "/godebug/non-default-behavior/gotypesalias:events": "go_godebug_non_default_behavior_gotypesalias_events_total", - "/godebug/non-default-behavior/http2client:events": "go_godebug_non_default_behavior_http2client_events_total", - "/godebug/non-default-behavior/http2server:events": "go_godebug_non_default_behavior_http2server_events_total", - "/godebug/non-default-behavior/httplaxcontentlength:events": "go_godebug_non_default_behavior_httplaxcontentlength_events_total", - "/godebug/non-default-behavior/httpmuxgo121:events": "go_godebug_non_default_behavior_httpmuxgo121_events_total", - "/godebug/non-default-behavior/installgoroot:events": "go_godebug_non_default_behavior_installgoroot_events_total", - "/godebug/non-default-behavior/jstmpllitinterp:events": "go_godebug_non_default_behavior_jstmpllitinterp_events_total", - "/godebug/non-default-behavior/multipartmaxheaders:events": "go_godebug_non_default_behavior_multipartmaxheaders_events_total", - "/godebug/non-default-behavior/multipartmaxparts:events": "go_godebug_non_default_behavior_multipartmaxparts_events_total", - "/godebug/non-default-behavior/multipathtcp:events": "go_godebug_non_default_behavior_multipathtcp_events_total", - "/godebug/non-default-behavior/netedns0:events": "go_godebug_non_default_behavior_netedns0_events_total", - "/godebug/non-default-behavior/panicnil:events": "go_godebug_non_default_behavior_panicnil_events_total", - "/godebug/non-default-behavior/randautoseed:events": "go_godebug_non_default_behavior_randautoseed_events_total", - "/godebug/non-default-behavior/tarinsecurepath:events": "go_godebug_non_default_behavior_tarinsecurepath_events_total", - "/godebug/non-default-behavior/tls10server:events": "go_godebug_non_default_behavior_tls10server_events_total", - "/godebug/non-default-behavior/tlsmaxrsasize:events": "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", - "/godebug/non-default-behavior/tlsrsakex:events": "go_godebug_non_default_behavior_tlsrsakex_events_total", - "/godebug/non-default-behavior/tlsunsafeekm:events": "go_godebug_non_default_behavior_tlsunsafeekm_events_total", - "/godebug/non-default-behavior/x509sha1:events": "go_godebug_non_default_behavior_x509sha1_events_total", - "/godebug/non-default-behavior/x509usefallbackroots:events": "go_godebug_non_default_behavior_x509usefallbackroots_events_total", - "/godebug/non-default-behavior/x509usepolicies:events": "go_godebug_non_default_behavior_x509usepolicies_events_total", - "/godebug/non-default-behavior/zipinsecurepath:events": "go_godebug_non_default_behavior_zipinsecurepath_events_total", - "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", - "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", - "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", - "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", - "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", - "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", - "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", - "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", - "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", - "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", - "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", - "/memory/classes/other:bytes": "go_memory_classes_other_bytes", - "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", - "/memory/classes/total:bytes": "go_memory_classes_total_bytes", - "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", - "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", - "/sched/latencies:seconds": "go_sched_latencies_seconds", - "/sched/pauses/stopping/gc:seconds": "go_sched_pauses_stopping_gc_seconds", - "/sched/pauses/stopping/other:seconds": "go_sched_pauses_stopping_other_seconds", - "/sched/pauses/total/gc:seconds": "go_sched_pauses_total_gc_seconds", - "/sched/pauses/total/other:seconds": "go_sched_pauses_total_other_seconds", - "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", -} +var ( + expectedRuntimeMetrics = map[string]string{ + "/cgo/go-to-c-calls:calls": "go_cgo_go_to_c_calls_calls_total", + "/cpu/classes/gc/mark/assist:cpu-seconds": "go_cpu_classes_gc_mark_assist_cpu_seconds_total", + "/cpu/classes/gc/mark/dedicated:cpu-seconds": "go_cpu_classes_gc_mark_dedicated_cpu_seconds_total", + "/cpu/classes/gc/mark/idle:cpu-seconds": "go_cpu_classes_gc_mark_idle_cpu_seconds_total", + "/cpu/classes/gc/pause:cpu-seconds": "go_cpu_classes_gc_pause_cpu_seconds_total", + "/cpu/classes/gc/total:cpu-seconds": "go_cpu_classes_gc_total_cpu_seconds_total", + "/cpu/classes/idle:cpu-seconds": "go_cpu_classes_idle_cpu_seconds_total", + "/cpu/classes/scavenge/assist:cpu-seconds": "go_cpu_classes_scavenge_assist_cpu_seconds_total", + "/cpu/classes/scavenge/background:cpu-seconds": "go_cpu_classes_scavenge_background_cpu_seconds_total", + "/cpu/classes/scavenge/total:cpu-seconds": "go_cpu_classes_scavenge_total_cpu_seconds_total", + "/cpu/classes/total:cpu-seconds": "go_cpu_classes_total_cpu_seconds_total", + "/cpu/classes/user:cpu-seconds": "go_cpu_classes_user_cpu_seconds_total", + "/gc/cycles/automatic:gc-cycles": "go_gc_cycles_automatic_gc_cycles_total", + "/gc/cycles/forced:gc-cycles": "go_gc_cycles_forced_gc_cycles_total", + "/gc/cycles/total:gc-cycles": "go_gc_cycles_total_gc_cycles_total", + "/gc/gogc:percent": "go_gc_gogc_percent", + "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", + "/gc/heap/allocs-by-size:bytes": "go_gc_heap_allocs_by_size_bytes", + "/gc/heap/allocs:bytes": "go_gc_heap_allocs_bytes_total", + "/gc/heap/allocs:objects": "go_gc_heap_allocs_objects_total", + "/gc/heap/frees-by-size:bytes": "go_gc_heap_frees_by_size_bytes", + "/gc/heap/frees:bytes": "go_gc_heap_frees_bytes_total", + "/gc/heap/frees:objects": "go_gc_heap_frees_objects_total", + "/gc/heap/goal:bytes": "go_gc_heap_goal_bytes", + "/gc/heap/live:bytes": "go_gc_heap_live_bytes", + "/gc/heap/objects:objects": "go_gc_heap_objects_objects", + "/gc/heap/tiny/allocs:objects": "go_gc_heap_tiny_allocs_objects_total", + "/gc/limiter/last-enabled:gc-cycle": "go_gc_limiter_last_enabled_gc_cycle", + "/gc/pauses:seconds": "go_gc_pauses_seconds", + "/gc/scan/globals:bytes": "go_gc_scan_globals_bytes", + "/gc/scan/heap:bytes": "go_gc_scan_heap_bytes", + "/gc/scan/stack:bytes": "go_gc_scan_stack_bytes", + "/gc/scan/total:bytes": "go_gc_scan_total_bytes", + "/gc/stack/starting-size:bytes": "go_gc_stack_starting_size_bytes", + "/godebug/non-default-behavior/execerrdot:events": "go_godebug_non_default_behavior_execerrdot_events_total", + "/godebug/non-default-behavior/gocachehash:events": "go_godebug_non_default_behavior_gocachehash_events_total", + "/godebug/non-default-behavior/gocachetest:events": "go_godebug_non_default_behavior_gocachetest_events_total", + "/godebug/non-default-behavior/gocacheverify:events": "go_godebug_non_default_behavior_gocacheverify_events_total", + "/godebug/non-default-behavior/gotypesalias:events": "go_godebug_non_default_behavior_gotypesalias_events_total", + "/godebug/non-default-behavior/http2client:events": "go_godebug_non_default_behavior_http2client_events_total", + "/godebug/non-default-behavior/http2server:events": "go_godebug_non_default_behavior_http2server_events_total", + "/godebug/non-default-behavior/httplaxcontentlength:events": "go_godebug_non_default_behavior_httplaxcontentlength_events_total", + "/godebug/non-default-behavior/httpmuxgo121:events": "go_godebug_non_default_behavior_httpmuxgo121_events_total", + "/godebug/non-default-behavior/installgoroot:events": "go_godebug_non_default_behavior_installgoroot_events_total", + "/godebug/non-default-behavior/jstmpllitinterp:events": "go_godebug_non_default_behavior_jstmpllitinterp_events_total", + "/godebug/non-default-behavior/multipartmaxheaders:events": "go_godebug_non_default_behavior_multipartmaxheaders_events_total", + "/godebug/non-default-behavior/multipartmaxparts:events": "go_godebug_non_default_behavior_multipartmaxparts_events_total", + "/godebug/non-default-behavior/multipathtcp:events": "go_godebug_non_default_behavior_multipathtcp_events_total", + "/godebug/non-default-behavior/netedns0:events": "go_godebug_non_default_behavior_netedns0_events_total", + "/godebug/non-default-behavior/panicnil:events": "go_godebug_non_default_behavior_panicnil_events_total", + "/godebug/non-default-behavior/randautoseed:events": "go_godebug_non_default_behavior_randautoseed_events_total", + "/godebug/non-default-behavior/tarinsecurepath:events": "go_godebug_non_default_behavior_tarinsecurepath_events_total", + "/godebug/non-default-behavior/tls10server:events": "go_godebug_non_default_behavior_tls10server_events_total", + "/godebug/non-default-behavior/tlsmaxrsasize:events": "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", + "/godebug/non-default-behavior/tlsrsakex:events": "go_godebug_non_default_behavior_tlsrsakex_events_total", + "/godebug/non-default-behavior/tlsunsafeekm:events": "go_godebug_non_default_behavior_tlsunsafeekm_events_total", + "/godebug/non-default-behavior/x509sha1:events": "go_godebug_non_default_behavior_x509sha1_events_total", + "/godebug/non-default-behavior/x509usefallbackroots:events": "go_godebug_non_default_behavior_x509usefallbackroots_events_total", + "/godebug/non-default-behavior/x509usepolicies:events": "go_godebug_non_default_behavior_x509usepolicies_events_total", + "/godebug/non-default-behavior/zipinsecurepath:events": "go_godebug_non_default_behavior_zipinsecurepath_events_total", + "/memory/classes/heap/free:bytes": "go_memory_classes_heap_free_bytes", + "/memory/classes/heap/objects:bytes": "go_memory_classes_heap_objects_bytes", + "/memory/classes/heap/released:bytes": "go_memory_classes_heap_released_bytes", + "/memory/classes/heap/stacks:bytes": "go_memory_classes_heap_stacks_bytes", + "/memory/classes/heap/unused:bytes": "go_memory_classes_heap_unused_bytes", + "/memory/classes/metadata/mcache/free:bytes": "go_memory_classes_metadata_mcache_free_bytes", + "/memory/classes/metadata/mcache/inuse:bytes": "go_memory_classes_metadata_mcache_inuse_bytes", + "/memory/classes/metadata/mspan/free:bytes": "go_memory_classes_metadata_mspan_free_bytes", + "/memory/classes/metadata/mspan/inuse:bytes": "go_memory_classes_metadata_mspan_inuse_bytes", + "/memory/classes/metadata/other:bytes": "go_memory_classes_metadata_other_bytes", + "/memory/classes/os-stacks:bytes": "go_memory_classes_os_stacks_bytes", + "/memory/classes/other:bytes": "go_memory_classes_other_bytes", + "/memory/classes/profiling/buckets:bytes": "go_memory_classes_profiling_buckets_bytes", + "/memory/classes/total:bytes": "go_memory_classes_total_bytes", + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + "/sched/goroutines:goroutines": "go_sched_goroutines_goroutines", + "/sched/latencies:seconds": "go_sched_latencies_seconds", + "/sched/pauses/stopping/gc:seconds": "go_sched_pauses_stopping_gc_seconds", + "/sched/pauses/stopping/other:seconds": "go_sched_pauses_stopping_other_seconds", + "/sched/pauses/total/gc:seconds": "go_sched_pauses_total_gc_seconds", + "/sched/pauses/total/other:seconds": "go_sched_pauses_total_other_seconds", + "/sync/mutex/wait/total:seconds": "go_sync_mutex_wait_total_seconds_total", + } + + expMetrics = map[string]string{ + "/gc/gogc:percent": "go_gc_gogc_percent", + "/gc/gomemlimit:bytes": "go_gc_gomemlimit_bytes", + "/sched/gomaxprocs:threads": "go_sched_gomaxprocs_threads", + } +) const expectedRuntimeMetricsCardinality = 162 diff --git a/prometheus/internal/go_collector_options.go b/prometheus/internal/go_collector_options.go index 723b45d64..a4fa6eabd 100644 --- a/prometheus/internal/go_collector_options.go +++ b/prometheus/internal/go_collector_options.go @@ -30,3 +30,5 @@ type GoCollectorOptions struct { RuntimeMetricSumForHist map[string]string RuntimeMetricRules []GoCollectorRule } + +var GoCollectorDefaultRuntimeMetrics = regexp.MustCompile(`/gc/gogc:percent|/gc/gomemlimit:bytes|/sched/gomaxprocs:threads`)