diff --git a/.github/settings.yml b/.github/settings.yml index f2a465bda..e78499030 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -21,8 +21,6 @@ branches: # Required. The list of status checks to require in order to merge into this branch contexts: - DCO - - "ci/circleci: go-1-17" - - "ci/circleci: go-1-18" # Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable. enforce_admins: false # Prevent merge commits from being pushed to matching branches diff --git a/prometheus/collectors/go_collector_go116.go b/prometheus/collectors/go_collector_go116.go deleted file mode 100644 index effc57840..000000000 --- a/prometheus/collectors/go_collector_go116.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2021 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.17 -// +build !go1.17 - -package collectors - -import "github.com/prometheus/client_golang/prometheus" - -// NewGoCollector returns a collector that exports metrics about the current Go -// process. This includes memory stats. To collect those, runtime.ReadMemStats -// is called. This requires to “stop the world”, which usually only happens for -// garbage collection (GC). Take the following implications into account when -// deciding whether to use the Go collector: -// -// 1. The performance impact of stopping the world is the more relevant the more -// frequently metrics are collected. However, with Go1.9 or later the -// stop-the-world time per metrics collection is very short (~25µs) so that the -// performance impact will only matter in rare cases. However, with older Go -// versions, the stop-the-world duration depends on the heap size and can be -// quite significant (~1.7 ms/GiB as per -// https://go-review.googlesource.com/c/go/+/34937). -// -// 2. During an ongoing GC, nothing else can stop the world. Therefore, if the -// metrics collection happens to coincide with GC, it will only complete after -// GC has finished. Usually, GC is fast enough to not cause problems. However, -// with a very large heap, GC might take multiple seconds, which is enough to -// cause scrape timeouts in common setups. To avoid this problem, the Go -// collector will use the memstats from a previous collection if -// runtime.ReadMemStats takes more than 1s. However, if there are no previously -// collected memstats, or their collection is more than 5m ago, the collection -// will block until runtime.ReadMemStats succeeds. -// -// NOTE: The problem is solved in Go 1.15, see -// https://github.com/golang/go/issues/19812 for the related Go issue. -func NewGoCollector() prometheus.Collector { - return prometheus.NewGoCollector() -} diff --git a/prometheus/collectors/go_collector_go120_test.go b/prometheus/collectors/go_collector_go120_test.go deleted file mode 100644 index e67fea10e..000000000 --- a/prometheus/collectors/go_collector_go120_test.go +++ /dev/null @@ -1,128 +0,0 @@ -// 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build go1.20 && !go1.21 -// +build go1.20,!go1.21 - -package collectors - -func withAllMetrics() []string { - return withBaseMetrics([]string{ - "go_cgo_go_to_c_calls_calls_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", - "go_cpu_classes_gc_pause_cpu_seconds_total", - "go_cpu_classes_gc_total_cpu_seconds_total", - "go_cpu_classes_idle_cpu_seconds_total", - "go_cpu_classes_scavenge_assist_cpu_seconds_total", - "go_cpu_classes_scavenge_background_cpu_seconds_total", - "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", - "go_gc_heap_frees_by_size_bytes", - "go_gc_heap_frees_bytes_total", - "go_gc_heap_frees_objects_total", - "go_gc_heap_goal_bytes", - "go_gc_heap_objects_objects", - "go_gc_heap_tiny_allocs_objects_total", - "go_gc_limiter_last_enabled_gc_cycle", - "go_gc_pauses_seconds", - "go_gc_stack_starting_size_bytes", - "go_memory_classes_heap_free_bytes", - "go_memory_classes_heap_objects_bytes", - "go_memory_classes_heap_released_bytes", - "go_memory_classes_heap_stacks_bytes", - "go_memory_classes_heap_unused_bytes", - "go_memory_classes_metadata_mcache_free_bytes", - "go_memory_classes_metadata_mcache_inuse_bytes", - "go_memory_classes_metadata_mspan_free_bytes", - "go_memory_classes_metadata_mspan_inuse_bytes", - "go_memory_classes_metadata_other_bytes", - "go_memory_classes_os_stacks_bytes", - "go_memory_classes_other_bytes", - "go_memory_classes_profiling_buckets_bytes", - "go_memory_classes_total_bytes", - "go_sched_gomaxprocs_threads", - "go_sched_goroutines_goroutines", - "go_sched_latencies_seconds", - "go_sync_mutex_wait_total_seconds_total", - }) -} - -func withGCMetrics() []string { - return withBaseMetrics([]string{ - "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", - "go_gc_heap_frees_by_size_bytes", - "go_gc_heap_frees_bytes_total", - "go_gc_heap_frees_objects_total", - "go_gc_heap_goal_bytes", - "go_gc_heap_objects_objects", - "go_gc_heap_tiny_allocs_objects_total", - "go_gc_limiter_last_enabled_gc_cycle", - "go_gc_pauses_seconds", - "go_gc_stack_starting_size_bytes", - }) -} - -func withMemoryMetrics() []string { - return withBaseMetrics([]string{ - "go_memory_classes_heap_free_bytes", - "go_memory_classes_heap_objects_bytes", - "go_memory_classes_heap_released_bytes", - "go_memory_classes_heap_stacks_bytes", - "go_memory_classes_heap_unused_bytes", - "go_memory_classes_metadata_mcache_free_bytes", - "go_memory_classes_metadata_mcache_inuse_bytes", - "go_memory_classes_metadata_mspan_free_bytes", - "go_memory_classes_metadata_mspan_inuse_bytes", - "go_memory_classes_metadata_other_bytes", - "go_memory_classes_os_stacks_bytes", - "go_memory_classes_other_bytes", - "go_memory_classes_profiling_buckets_bytes", - "go_memory_classes_total_bytes", - }) -} - -func withSchedulerMetrics() []string { - return withBaseMetrics([]string{ - "go_sched_gomaxprocs_threads", - "go_sched_goroutines_goroutines", - "go_sched_latencies_seconds", - }) -} - -func withDebugMetrics() []string { - return withBaseMetrics([]string{}) -} - -var ( - defaultRuntimeMetrics = []string{ - "go_sched_gomaxprocs_threads", - } - onlyGCDefRuntimeMetrics = []string{} - onlySchedDefRuntimeMetrics = []string{ - "go_sched_gomaxprocs_threads", - } -) diff --git a/prometheus/collectors/go_collector_go121_test.go b/prometheus/collectors/go_collector_go121_test.go deleted file mode 100644 index f8a5879af..000000000 --- a/prometheus/collectors/go_collector_go121_test.go +++ /dev/null @@ -1,186 +0,0 @@ -// 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build go1.21 && !go1.22 -// +build go1.21,!go1.22 - -package collectors - -func withAllMetrics() []string { - return withBaseMetrics([]string{ - "go_cgo_go_to_c_calls_calls_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", - "go_cpu_classes_gc_pause_cpu_seconds_total", - "go_cpu_classes_gc_total_cpu_seconds_total", - "go_cpu_classes_idle_cpu_seconds_total", - "go_cpu_classes_scavenge_assist_cpu_seconds_total", - "go_cpu_classes_scavenge_background_cpu_seconds_total", - "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_gogc_percent", - "go_gc_gomemlimit_bytes", - "go_gc_heap_allocs_by_size_bytes", - "go_gc_heap_allocs_bytes_total", - "go_gc_heap_allocs_objects_total", - "go_gc_heap_frees_by_size_bytes", - "go_gc_heap_frees_bytes_total", - "go_gc_heap_frees_objects_total", - "go_gc_heap_goal_bytes", - "go_gc_heap_live_bytes", - "go_gc_heap_objects_objects", - "go_gc_heap_tiny_allocs_objects_total", - "go_gc_limiter_last_enabled_gc_cycle", - "go_gc_pauses_seconds", - "go_gc_scan_globals_bytes", - "go_gc_scan_heap_bytes", - "go_gc_scan_stack_bytes", - "go_gc_scan_total_bytes", - "go_gc_stack_starting_size_bytes", - "go_godebug_non_default_behavior_execerrdot_events_total", - "go_godebug_non_default_behavior_gocachehash_events_total", - "go_godebug_non_default_behavior_gocachetest_events_total", - "go_godebug_non_default_behavior_gocacheverify_events_total", - "go_godebug_non_default_behavior_http2client_events_total", - "go_godebug_non_default_behavior_http2server_events_total", - "go_godebug_non_default_behavior_installgoroot_events_total", - "go_godebug_non_default_behavior_jstmpllitinterp_events_total", - "go_godebug_non_default_behavior_multipartmaxheaders_events_total", - "go_godebug_non_default_behavior_multipartmaxparts_events_total", - "go_godebug_non_default_behavior_multipathtcp_events_total", - "go_godebug_non_default_behavior_netedns0_events_total", - "go_godebug_non_default_behavior_panicnil_events_total", - "go_godebug_non_default_behavior_randautoseed_events_total", - "go_godebug_non_default_behavior_tarinsecurepath_events_total", - "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", - "go_godebug_non_default_behavior_x509sha1_events_total", - "go_godebug_non_default_behavior_x509usefallbackroots_events_total", - "go_godebug_non_default_behavior_zipinsecurepath_events_total", - "go_memory_classes_heap_free_bytes", - "go_memory_classes_heap_objects_bytes", - "go_memory_classes_heap_released_bytes", - "go_memory_classes_heap_stacks_bytes", - "go_memory_classes_heap_unused_bytes", - "go_memory_classes_metadata_mcache_free_bytes", - "go_memory_classes_metadata_mcache_inuse_bytes", - "go_memory_classes_metadata_mspan_free_bytes", - "go_memory_classes_metadata_mspan_inuse_bytes", - "go_memory_classes_metadata_other_bytes", - "go_memory_classes_os_stacks_bytes", - "go_memory_classes_other_bytes", - "go_memory_classes_profiling_buckets_bytes", - "go_memory_classes_total_bytes", - "go_sched_gomaxprocs_threads", - "go_sched_goroutines_goroutines", - "go_sched_latencies_seconds", - "go_sync_mutex_wait_total_seconds_total", - }) -} - -func withGCMetrics() []string { - return withBaseMetrics([]string{ - "go_gc_cycles_automatic_gc_cycles_total", - "go_gc_cycles_forced_gc_cycles_total", - "go_gc_cycles_total_gc_cycles_total", - "go_gc_gogc_percent", - "go_gc_gomemlimit_bytes", - "go_gc_heap_allocs_by_size_bytes", - "go_gc_heap_allocs_bytes_total", - "go_gc_heap_allocs_objects_total", - "go_gc_heap_frees_by_size_bytes", - "go_gc_heap_frees_bytes_total", - "go_gc_heap_frees_objects_total", - "go_gc_heap_goal_bytes", - "go_gc_heap_live_bytes", - "go_gc_heap_objects_objects", - "go_gc_heap_tiny_allocs_objects_total", - "go_gc_limiter_last_enabled_gc_cycle", - "go_gc_pauses_seconds", - "go_gc_scan_globals_bytes", - "go_gc_scan_heap_bytes", - "go_gc_scan_stack_bytes", - "go_gc_scan_total_bytes", - "go_gc_stack_starting_size_bytes", - }) -} - -func withMemoryMetrics() []string { - return withBaseMetrics([]string{ - "go_memory_classes_heap_free_bytes", - "go_memory_classes_heap_objects_bytes", - "go_memory_classes_heap_released_bytes", - "go_memory_classes_heap_stacks_bytes", - "go_memory_classes_heap_unused_bytes", - "go_memory_classes_metadata_mcache_free_bytes", - "go_memory_classes_metadata_mcache_inuse_bytes", - "go_memory_classes_metadata_mspan_free_bytes", - "go_memory_classes_metadata_mspan_inuse_bytes", - "go_memory_classes_metadata_other_bytes", - "go_memory_classes_os_stacks_bytes", - "go_memory_classes_other_bytes", - "go_memory_classes_profiling_buckets_bytes", - "go_memory_classes_total_bytes", - }) -} - -func withSchedulerMetrics() []string { - return withBaseMetrics([]string{ - "go_sched_gomaxprocs_threads", - "go_sched_goroutines_goroutines", - "go_sched_latencies_seconds", - }) -} - -func withDebugMetrics() []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", - "go_godebug_non_default_behavior_gocacheverify_events_total", - "go_godebug_non_default_behavior_http2client_events_total", - "go_godebug_non_default_behavior_http2server_events_total", - "go_godebug_non_default_behavior_installgoroot_events_total", - "go_godebug_non_default_behavior_jstmpllitinterp_events_total", - "go_godebug_non_default_behavior_multipartmaxheaders_events_total", - "go_godebug_non_default_behavior_multipartmaxparts_events_total", - "go_godebug_non_default_behavior_multipathtcp_events_total", - "go_godebug_non_default_behavior_netedns0_events_total", - "go_godebug_non_default_behavior_panicnil_events_total", - "go_godebug_non_default_behavior_randautoseed_events_total", - "go_godebug_non_default_behavior_tarinsecurepath_events_total", - "go_godebug_non_default_behavior_tlsmaxrsasize_events_total", - "go_godebug_non_default_behavior_x509sha1_events_total", - "go_godebug_non_default_behavior_x509usefallbackroots_events_total", - "go_godebug_non_default_behavior_zipinsecurepath_events_total", - }) -} - -var ( - defaultRuntimeMetrics = []string{ - "go_gc_gogc_percent", - "go_gc_gomemlimit_bytes", - "go_sched_gomaxprocs_threads", - } - onlyGCDefRuntimeMetrics = []string{ - "go_gc_gogc_percent", - "go_gc_gomemlimit_bytes", - } - onlySchedDefRuntimeMetrics = []string{ - "go_sched_gomaxprocs_threads", - } -) diff --git a/prometheus/go_collector_go116.go b/prometheus/go_collector_go116.go deleted file mode 100644 index 897a6e906..000000000 --- a/prometheus/go_collector_go116.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2021 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.17 -// +build !go1.17 - -package prometheus - -import ( - "runtime" - "sync" - "time" -) - -type goCollector struct { - base baseGoCollector - - // ms... are memstats related. - msLast *runtime.MemStats // Previously collected memstats. - msLastTimestamp time.Time - msMtx sync.Mutex // Protects msLast and msLastTimestamp. - msMetrics memStatsMetrics - msRead func(*runtime.MemStats) // For mocking in tests. - msMaxWait time.Duration // Wait time for fresh memstats. - msMaxAge time.Duration // Maximum allowed age of old memstats. -} - -// NewGoCollector is the obsolete version of collectors.NewGoCollector. -// See there for documentation. -// -// Deprecated: Use collectors.NewGoCollector instead. -func NewGoCollector() Collector { - msMetrics := goRuntimeMemStats() - msMetrics = append(msMetrics, struct { - desc *Desc - eval func(*runtime.MemStats) float64 - valType ValueType - }{ - // This metric is omitted in Go1.17+, see https://github.com/prometheus/client_golang/issues/842#issuecomment-861812034 - desc: NewDesc( - memstatNamespace("gc_cpu_fraction"), - "The fraction of this program's available CPU time used by the GC since the program started.", - nil, nil, - ), - eval: func(ms *runtime.MemStats) float64 { return ms.GCCPUFraction }, - valType: GaugeValue, - }) - return &goCollector{ - base: newBaseGoCollector(), - msLast: &runtime.MemStats{}, - msRead: runtime.ReadMemStats, - msMaxWait: time.Second, - msMaxAge: 5 * time.Minute, - msMetrics: msMetrics, - } -} - -// Describe returns all descriptions of the collector. -func (c *goCollector) Describe(ch chan<- *Desc) { - c.base.Describe(ch) - for _, i := range c.msMetrics { - ch <- i.desc - } -} - -// Collect returns the current state of all metrics of the collector. -func (c *goCollector) Collect(ch chan<- Metric) { - var ( - ms = &runtime.MemStats{} - done = make(chan struct{}) - ) - // Start reading memstats first as it might take a while. - go func() { - c.msRead(ms) - c.msMtx.Lock() - c.msLast = ms - c.msLastTimestamp = time.Now() - c.msMtx.Unlock() - close(done) - }() - - // Collect base non-memory metrics. - c.base.Collect(ch) - - timer := time.NewTimer(c.msMaxWait) - select { - case <-done: // Our own ReadMemStats succeeded in time. Use it. - timer.Stop() // Important for high collection frequencies to not pile up timers. - c.msCollect(ch, ms) - return - case <-timer.C: // Time out, use last memstats if possible. Continue below. - } - c.msMtx.Lock() - if time.Since(c.msLastTimestamp) < c.msMaxAge { - // Last memstats are recent enough. Collect from them under the lock. - c.msCollect(ch, c.msLast) - c.msMtx.Unlock() - return - } - // If we are here, the last memstats are too old or don't exist. We have - // to wait until our own ReadMemStats finally completes. For that to - // happen, we have to release the lock. - c.msMtx.Unlock() - <-done - c.msCollect(ch, ms) -} - -func (c *goCollector) msCollect(ch chan<- Metric, ms *runtime.MemStats) { - for _, i := range c.msMetrics { - ch <- MustNewConstMetric(i.desc, i.valType, i.eval(ms)) - } -} diff --git a/prometheus/go_collector_go116_test.go b/prometheus/go_collector_go116_test.go deleted file mode 100644 index 8969f38a1..000000000 --- a/prometheus/go_collector_go116_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2021 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. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.17 -// +build !go1.17 - -package prometheus - -import ( - "runtime" - "testing" - "time" - - dto "github.com/prometheus/client_model/go" -) - -func TestGoCollectorMemStats(t *testing.T) { - var ( - c = NewGoCollector().(*goCollector) - got uint64 - ) - - checkCollect := func(want uint64) { - metricCh := make(chan Metric) - endCh := make(chan struct{}) - - go func() { - c.Collect(metricCh) - close(endCh) - }() - Collect: - for { - select { - case metric := <-metricCh: - if metric.Desc().fqName != "go_memstats_alloc_bytes" { - continue Collect - } - pb := &dto.Metric{} - metric.Write(pb) - got = uint64(pb.GetGauge().GetValue()) - case <-endCh: - break Collect - } - } - if want != got { - t.Errorf("unexpected value of go_memstats_alloc_bytes, want %d, got %d", want, got) - } - } - - // Speed up the timing to make the test faster. - c.msMaxWait = 5 * time.Millisecond - c.msMaxAge = 50 * time.Millisecond - - // Scenario 1: msRead responds slowly, no previous memstats available, - // msRead is executed anyway. - c.msRead = func(ms *runtime.MemStats) { - time.Sleep(20 * time.Millisecond) - ms.Alloc = 1 - } - checkCollect(1) - // Now msLast is set. - c.msMtx.Lock() - if want, got := uint64(1), c.msLast.Alloc; want != got { - t.Errorf("unexpected of msLast.Alloc, want %d, got %d", want, got) - } - c.msMtx.Unlock() - - // Scenario 2: msRead responds fast, previous memstats available, new - // value collected. - c.msRead = func(ms *runtime.MemStats) { - ms.Alloc = 2 - } - checkCollect(2) - // msLast is set, too. - c.msMtx.Lock() - if want, got := uint64(2), c.msLast.Alloc; want != got { - t.Errorf("unexpected of msLast.Alloc, want %d, got %d", want, got) - } - c.msMtx.Unlock() - - // Scenario 3: msRead responds slowly, previous memstats available, old - // value collected. - c.msRead = func(ms *runtime.MemStats) { - time.Sleep(20 * time.Millisecond) - ms.Alloc = 3 - } - checkCollect(2) - // After waiting, new value is still set in msLast. - time.Sleep(80 * time.Millisecond) - c.msMtx.Lock() - if want, got := uint64(3), c.msLast.Alloc; want != got { - t.Errorf("unexpected of msLast.Alloc, want %d, got %d", want, got) - } - c.msMtx.Unlock() - - // Scenario 4: msRead responds slowly, previous memstats is too old, new - // value collected. - c.msRead = func(ms *runtime.MemStats) { - time.Sleep(20 * time.Millisecond) - ms.Alloc = 4 - } - checkCollect(4) - c.msMtx.Lock() - if want, got := uint64(4), c.msLast.Alloc; want != got { - t.Errorf("unexpected of msLast.Alloc, want %d, got %d", want, got) - } - c.msMtx.Unlock() -} diff --git a/prometheus/go_collector_metrics_go120_test.go b/prometheus/go_collector_metrics_go120_test.go deleted file mode 100644 index 4c1ca38d3..000000000 --- a/prometheus/go_collector_metrics_go120_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by gen_go_collector_metrics_set.go; DO NOT EDIT. -//go:generate go run gen_go_collector_metrics_set.go go1.20 - -//go:build go1.20 && !go1.21 -// +build go1.20,!go1.21 - -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", - } - - 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 deleted file mode 100644 index 217b04fc7..000000000 --- a/prometheus/go_collector_metrics_go121_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by gen_go_collector_metrics_set.go; DO NOT EDIT. -//go:generate go run gen_go_collector_metrics_set.go go1.21 - -//go:build go1.21 && !go1.22 -// +build go1.21,!go1.22 - -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", - } - - 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