Skip to content

Commit 06d4592

Browse files
authored
Add Go 1.21 support (#1325)
* Add Go 1.21 support Signed-off-by: Kemal Akkoyun <[email protected]> * Update README.md Signed-off-by: Kemal Akkoyun <[email protected]> --------- Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent cdd7f45 commit 06d4592

File tree

6 files changed

+260
-7
lines changed

6 files changed

+260
-7
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
branches:
77
- main
8-
- 'release-*'
8+
- "release-*"
99

1010
# Minimal permissions to be inherited by any job that don't declare it's own permissions
1111
permissions:
@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
go_version: ["1.18", "1.19", "1.20"]
21+
go_version: ["1.19", "1.20", "1.21"]
2222

2323
steps:
2424
- name: Checkout code

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.18
1+
1.21

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test: deps common-test
2121
test-short: deps common-test-short
2222

2323
.PHONY: generate-go-collector-test-files
24-
VERSIONS := 1.17 1.18 1.19 1.20
24+
VERSIONS := 1.19 1.20 1.21
2525
generate-go-collector-test-files:
2626
for GO_VERSION in $(VERSIONS); do \
2727
docker run --rm -v $(PWD):/workspace -w /workspace golang:$$GO_VERSION go run prometheus/gen_go_collector_metrics_set.go; \
@@ -31,4 +31,3 @@ generate-go-collector-test-files:
3131
.PHONY: fmt
3232
fmt: common-format
3333
$(GOIMPORTS) -local github.com/prometheus/client_golang -w .
34-

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ This is the [Go](http://golang.org) client library for
1010
instrumenting application code, and one for creating clients that talk to the
1111
Prometheus HTTP API.
1212

13-
__This library requires Go1.18 or later.__
13+
**This library requires Go1.19 or later.**
14+
> The library mandates the use of Go1.19 or subsequent versions. While it has demonstrated functionality with versions as old as Go 1.17, our commitment remains to offer support and rectifications for only the most recent three major releases.
1415
1516
## Important note about releases and stability
1617

1718
This repository generally follows [Semantic
1819
Versioning](https://semver.org/). However, the API client in
19-
prometheus/client_golang/api/… is still considered experimental. Breaking
20+
`prometheus/client_golang/api/…` is still considered experimental. Breaking
2021
changes of the API client will _not_ trigger a new major release. The same is
2122
true for selected other new features explicitly marked as **EXPERIMENTAL** in
2223
CHANGELOG.md.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// Copyright 2022 The Prometheus Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
//go:build go1.21 && !go1.22
15+
// +build go1.21,!go1.22
16+
17+
package collectors
18+
19+
func withAllMetrics() []string {
20+
return withBaseMetrics([]string{
21+
"go_cgo_go_to_c_calls_calls_total",
22+
"go_cpu_classes_gc_mark_assist_cpu_seconds_total",
23+
"go_cpu_classes_gc_mark_dedicated_cpu_seconds_total",
24+
"go_cpu_classes_gc_mark_idle_cpu_seconds_total",
25+
"go_cpu_classes_gc_pause_cpu_seconds_total",
26+
"go_cpu_classes_gc_total_cpu_seconds_total",
27+
"go_cpu_classes_idle_cpu_seconds_total",
28+
"go_cpu_classes_scavenge_assist_cpu_seconds_total",
29+
"go_cpu_classes_scavenge_background_cpu_seconds_total",
30+
"go_cpu_classes_scavenge_total_cpu_seconds_total",
31+
"go_cpu_classes_total_cpu_seconds_total",
32+
"go_cpu_classes_user_cpu_seconds_total",
33+
"go_gc_cycles_automatic_gc_cycles_total",
34+
"go_gc_cycles_forced_gc_cycles_total",
35+
"go_gc_cycles_total_gc_cycles_total",
36+
"go_gc_gogc_percent",
37+
"go_gc_gomemlimit_bytes",
38+
"go_gc_heap_allocs_by_size_bytes",
39+
"go_gc_heap_allocs_bytes_total",
40+
"go_gc_heap_allocs_objects_total",
41+
"go_gc_heap_frees_by_size_bytes",
42+
"go_gc_heap_frees_bytes_total",
43+
"go_gc_heap_frees_objects_total",
44+
"go_gc_heap_goal_bytes",
45+
"go_gc_heap_live_bytes",
46+
"go_gc_heap_objects_objects",
47+
"go_gc_heap_tiny_allocs_objects_total",
48+
"go_gc_limiter_last_enabled_gc_cycle",
49+
"go_gc_pauses_seconds",
50+
"go_gc_scan_globals_bytes",
51+
"go_gc_scan_heap_bytes",
52+
"go_gc_scan_stack_bytes",
53+
"go_gc_scan_total_bytes",
54+
"go_gc_stack_starting_size_bytes",
55+
"go_godebug_non_default_behavior_execerrdot_events_total",
56+
"go_godebug_non_default_behavior_gocachehash_events_total",
57+
"go_godebug_non_default_behavior_gocachetest_events_total",
58+
"go_godebug_non_default_behavior_gocacheverify_events_total",
59+
"go_godebug_non_default_behavior_http2client_events_total",
60+
"go_godebug_non_default_behavior_http2server_events_total",
61+
"go_godebug_non_default_behavior_installgoroot_events_total",
62+
"go_godebug_non_default_behavior_jstmpllitinterp_events_total",
63+
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
64+
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
65+
"go_godebug_non_default_behavior_multipathtcp_events_total",
66+
"go_godebug_non_default_behavior_panicnil_events_total",
67+
"go_godebug_non_default_behavior_randautoseed_events_total",
68+
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
69+
"go_godebug_non_default_behavior_x509sha1_events_total",
70+
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
71+
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
72+
"go_memory_classes_heap_free_bytes",
73+
"go_memory_classes_heap_objects_bytes",
74+
"go_memory_classes_heap_released_bytes",
75+
"go_memory_classes_heap_stacks_bytes",
76+
"go_memory_classes_heap_unused_bytes",
77+
"go_memory_classes_metadata_mcache_free_bytes",
78+
"go_memory_classes_metadata_mcache_inuse_bytes",
79+
"go_memory_classes_metadata_mspan_free_bytes",
80+
"go_memory_classes_metadata_mspan_inuse_bytes",
81+
"go_memory_classes_metadata_other_bytes",
82+
"go_memory_classes_os_stacks_bytes",
83+
"go_memory_classes_other_bytes",
84+
"go_memory_classes_profiling_buckets_bytes",
85+
"go_memory_classes_total_bytes",
86+
"go_sched_gomaxprocs_threads",
87+
"go_sched_goroutines_goroutines",
88+
"go_sched_latencies_seconds",
89+
"go_sync_mutex_wait_total_seconds_total",
90+
})
91+
}
92+
93+
func withGCMetrics() []string {
94+
return withBaseMetrics([]string{
95+
"go_gc_cycles_automatic_gc_cycles_total",
96+
"go_gc_cycles_forced_gc_cycles_total",
97+
"go_gc_cycles_total_gc_cycles_total",
98+
"go_gc_gogc_percent",
99+
"go_gc_gomemlimit_bytes",
100+
"go_gc_heap_allocs_by_size_bytes",
101+
"go_gc_heap_allocs_bytes_total",
102+
"go_gc_heap_allocs_objects_total",
103+
"go_gc_heap_frees_by_size_bytes",
104+
"go_gc_heap_frees_bytes_total",
105+
"go_gc_heap_frees_objects_total",
106+
"go_gc_heap_goal_bytes",
107+
"go_gc_heap_live_bytes",
108+
"go_gc_heap_objects_objects",
109+
"go_gc_heap_tiny_allocs_objects_total",
110+
"go_gc_limiter_last_enabled_gc_cycle",
111+
"go_gc_pauses_seconds",
112+
"go_gc_scan_globals_bytes",
113+
"go_gc_scan_heap_bytes",
114+
"go_gc_scan_stack_bytes",
115+
"go_gc_scan_total_bytes",
116+
"go_gc_stack_starting_size_bytes",
117+
})
118+
}
119+
120+
func withMemoryMetrics() []string {
121+
return withBaseMetrics([]string{
122+
"go_memory_classes_heap_free_bytes",
123+
"go_memory_classes_heap_objects_bytes",
124+
"go_memory_classes_heap_released_bytes",
125+
"go_memory_classes_heap_stacks_bytes",
126+
"go_memory_classes_heap_unused_bytes",
127+
"go_memory_classes_metadata_mcache_free_bytes",
128+
"go_memory_classes_metadata_mcache_inuse_bytes",
129+
"go_memory_classes_metadata_mspan_free_bytes",
130+
"go_memory_classes_metadata_mspan_inuse_bytes",
131+
"go_memory_classes_metadata_other_bytes",
132+
"go_memory_classes_os_stacks_bytes",
133+
"go_memory_classes_other_bytes",
134+
"go_memory_classes_profiling_buckets_bytes",
135+
"go_memory_classes_total_bytes",
136+
})
137+
}
138+
139+
func withSchedulerMetrics() []string {
140+
return []string{
141+
"go_gc_duration_seconds",
142+
"go_goroutines",
143+
"go_info",
144+
"go_memstats_last_gc_time_seconds",
145+
"go_sched_gomaxprocs_threads",
146+
"go_sched_goroutines_goroutines",
147+
"go_sched_latencies_seconds",
148+
"go_threads",
149+
}
150+
}
151+
152+
func withDebugMetrics() []string {
153+
return []string{
154+
"go_godebug_non_default_behavior_execerrdot_events_total",
155+
"go_godebug_non_default_behavior_gocachehash_events_total",
156+
"go_godebug_non_default_behavior_gocachetest_events_total",
157+
"go_godebug_non_default_behavior_gocacheverify_events_total",
158+
"go_godebug_non_default_behavior_http2client_events_total",
159+
"go_godebug_non_default_behavior_http2server_events_total",
160+
"go_godebug_non_default_behavior_installgoroot_events_total",
161+
"go_godebug_non_default_behavior_jstmpllitinterp_events_total",
162+
"go_godebug_non_default_behavior_multipartmaxheaders_events_total",
163+
"go_godebug_non_default_behavior_multipartmaxparts_events_total",
164+
"go_godebug_non_default_behavior_multipathtcp_events_total",
165+
"go_godebug_non_default_behavior_panicnil_events_total",
166+
"go_godebug_non_default_behavior_randautoseed_events_total",
167+
"go_godebug_non_default_behavior_tarinsecurepath_events_total",
168+
"go_godebug_non_default_behavior_x509sha1_events_total",
169+
"go_godebug_non_default_behavior_x509usefallbackroots_events_total",
170+
"go_godebug_non_default_behavior_zipinsecurepath_events_total",
171+
}
172+
}

prometheus/go_collector_metrics_go121_test.go

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)