From a420cd5b92ceec276b903fcb390aca2e03576c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20C=C3=A1rdenas?= Date: Thu, 26 Mar 2026 16:26:28 +0100 Subject: [PATCH 1/4] version: Include race build tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Cárdenas --- version/info.go | 9 ++++++++- version/info_norace.go | 18 ++++++++++++++++++ version/info_race.go | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 version/info_norace.go create mode 100644 version/info_race.go diff --git a/version/info.go b/version/info.go index 112f3552..c87f49a3 100644 --- a/version/info.go +++ b/version/info.go @@ -126,6 +126,9 @@ func computeRevision() (string, string) { tags = "unknown" modified bool ) + if race { + tags = "race" + } buildInfo, ok := debug.ReadBuildInfo() if !ok { @@ -141,7 +144,11 @@ func computeRevision() (string, string) { } } if v.Key == "-tags" { - tags = v.Value + if race { + tags = v.Value + ",race" + } else { + tags = v.Value + } } } if modified { diff --git a/version/info_norace.go b/version/info_norace.go new file mode 100644 index 00000000..78db5c96 --- /dev/null +++ b/version/info_norace.go @@ -0,0 +1,18 @@ +// Copyright 2026 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 !race + +package version + +var race = false diff --git a/version/info_race.go b/version/info_race.go new file mode 100644 index 00000000..4897ebe9 --- /dev/null +++ b/version/info_race.go @@ -0,0 +1,18 @@ +// Copyright 2026 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 race + +package version + +var race = true From dbd712a1c3c3dffb13fa92b077f0c1907b948617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20C=C3=A1rdenas?= Date: Thu, 26 Mar 2026 16:38:21 +0100 Subject: [PATCH 2/4] Fix license. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Cárdenas --- version/info_norace.go | 2 +- version/info_race.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/version/info_norace.go b/version/info_norace.go index 78db5c96..ed720e8e 100644 --- a/version/info_norace.go +++ b/version/info_norace.go @@ -1,4 +1,4 @@ -// Copyright 2026 The Prometheus Authors +// Copyright 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 diff --git a/version/info_race.go b/version/info_race.go index 4897ebe9..fbac6d96 100644 --- a/version/info_race.go +++ b/version/info_race.go @@ -1,4 +1,4 @@ -// Copyright 2026 The Prometheus Authors +// Copyright 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 From 54b595518f9ca5cc73072b9055fd6742dd91b6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20C=C3=A1rdenas?= Date: Mon, 6 Apr 2026 12:34:15 +0200 Subject: [PATCH 3/4] var -> const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Cárdenas --- version/info_norace.go | 2 +- version/info_race.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/version/info_norace.go b/version/info_norace.go index ed720e8e..be6939a1 100644 --- a/version/info_norace.go +++ b/version/info_norace.go @@ -15,4 +15,4 @@ package version -var race = false +const race = false diff --git a/version/info_race.go b/version/info_race.go index fbac6d96..67fecab9 100644 --- a/version/info_race.go +++ b/version/info_race.go @@ -15,4 +15,4 @@ package version -var race = true +const race = true From bd03eb9e0c98f88e4dd782e2d5765038897ececf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20C=C3=A1rdenas?= Date: Fri, 10 Apr 2026 13:23:56 +0200 Subject: [PATCH 4/4] Extract -race from buildInfo-Settings instead. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Cárdenas --- version/info.go | 29 +++++++++++++++++++---------- version/info_norace.go | 18 ------------------ version/info_race.go | 18 ------------------ 3 files changed, 19 insertions(+), 46 deletions(-) delete mode 100644 version/info_norace.go delete mode 100644 version/info_race.go diff --git a/version/info.go b/version/info.go index c87f49a3..fe9afa3a 100644 --- a/version/info.go +++ b/version/info.go @@ -123,16 +123,14 @@ func init() { func computeRevision() (string, string) { var ( rev = "unknown" - tags = "unknown" + tags string modified bool + race bool ) - if race { - tags = "race" - } buildInfo, ok := debug.ReadBuildInfo() if !ok { - return rev, tags + return rev, "unknown" } for _, v := range buildInfo.Settings { if v.Key == "vcs.revision" { @@ -144,13 +142,24 @@ func computeRevision() (string, string) { } } if v.Key == "-tags" { - if race { - tags = v.Value + ",race" - } else { - tags = v.Value - } + tags = v.Value + } + if !race && v.Key == "-race" && v.Value == "true" { + race = true + } + } + + if race { + if tags == "" { + tags = "race" + } else { + tags += ",race" } } + if tags == "" { + tags = "unknown" + } + if modified { return rev + "-modified", tags } diff --git a/version/info_norace.go b/version/info_norace.go deleted file mode 100644 index be6939a1..00000000 --- a/version/info_norace.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 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 !race - -package version - -const race = false diff --git a/version/info_race.go b/version/info_race.go deleted file mode 100644 index 67fecab9..00000000 --- a/version/info_race.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 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 race - -package version - -const race = true