diff --git a/.circleci/config.yml b/.circleci/config.yml index 64b08fc8..8e5fff95 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,15 +95,15 @@ workflows: matrix: parameters: go_version: - - "1.20" - "1.21" - "1.22" + - "1.23" - test-assets: name: assets-go-<< matrix.go_version >> matrix: parameters: go_version: - - "1.22" + - "1.23" - style: name: style - go_version: "1.22" + go_version: "1.23" diff --git a/assets/go.mod b/assets/go.mod index 1f13afcc..4f73955c 100644 --- a/assets/go.mod +++ b/assets/go.mod @@ -1,3 +1,3 @@ module github.com/prometheus/common/assets -go 1.20 +go 1.21 diff --git a/go.mod b/go.mod index 705440fb..b5b11c5e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/prometheus/common -go 1.20 +go 1.21 require ( github.com/alecthomas/kingpin/v2 v2.4.0 @@ -25,7 +25,7 @@ require ( github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.20.0 // indirect + github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect diff --git a/go.sum b/go.sum index a6d6bbf9..73c7c618 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,10 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -31,8 +33,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= -github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= diff --git a/model/labelset_go120_test.go b/model/labelset_go120_test.go deleted file mode 100644 index d3c00e8f..00000000 --- a/model/labelset_go120_test.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2024 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 - -package model - -import ( - "encoding/json" - "testing" -) - -func TestUnmarshalJSONLabelSet(t *testing.T) { - type testConfig struct { - LabelSet LabelSet `yaml:"labelSet,omitempty"` - } - - // valid LabelSet JSON - labelSetJSON := `{ - "labelSet": { - "monitor": "codelab", - "foo": "bar", - "foo2": "bar", - "abc": "prometheus", - "foo11": "bar11" - } -}` - var c testConfig - err := json.Unmarshal([]byte(labelSetJSON), &c) - if err != nil { - t.Errorf("unexpected error while marshalling JSON : %s", err.Error()) - } - - labelSetString := c.LabelSet.String() - - expected := `{abc="prometheus", foo="bar", foo11="bar11", foo2="bar", monitor="codelab"}` - - if expected != labelSetString { - t.Errorf("expected %s but got %s", expected, labelSetString) - } - - // invalid LabelSet JSON - invalidlabelSetJSON := `{ - "labelSet": { - "1nvalid_23name": "codelab", - "foo": "bar" - } -}` - - NameValidationScheme = LegacyValidation - err = json.Unmarshal([]byte(invalidlabelSetJSON), &c) - expectedErr := `"1nvalid_23name" is not a valid label name` - if err == nil || err.Error() != expectedErr { - t.Errorf("expected an error with message '%s' to be thrown", expectedErr) - } -} - -func TestLabelSetClone(t *testing.T) { - labelSet := LabelSet{ - "monitor": "codelab", - "foo": "bar", - "bar": "baz", - } - - cloneSet := labelSet.Clone() - - if len(labelSet) != len(cloneSet) { - t.Errorf("expected the length of the cloned Label set to be %d, but got %d", - len(labelSet), len(cloneSet)) - } - - for ln, lv := range labelSet { - expected := cloneSet[ln] - if expected != lv { - t.Errorf("expected to get LabelValue %s, but got %s for LabelName %s", expected, lv, ln) - } - } -} - -func TestLabelSetMerge(t *testing.T) { - labelSet := LabelSet{ - "monitor": "codelab", - "foo": "bar", - "bar": "baz", - } - - labelSet2 := LabelSet{ - "monitor": "codelab", - "dolor": "mi", - "lorem": "ipsum", - } - - expectedSet := LabelSet{ - "monitor": "codelab", - "foo": "bar", - "bar": "baz", - "dolor": "mi", - "lorem": "ipsum", - } - - mergedSet := labelSet.Merge(labelSet2) - - if len(mergedSet) != len(expectedSet) { - t.Errorf("expected the length of the cloned Label set to be %d, but got %d", - len(expectedSet), len(mergedSet)) - } - - for ln, lv := range mergedSet { - expected := expectedSet[ln] - if expected != lv { - t.Errorf("expected to get LabelValue %s, but got %s for LabelName %s", expected, lv, ln) - } - } -} - -// Benchmark Results for LabelSet's String() method -// --------------------------------------------------------------------------------------------------------- -// goos: linux -// goarch: amd64 -// pkg: github.com/prometheus/common/model -// cpu: 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz -// BenchmarkLabelSetStringMethod-8 732376 1532 ns/op - -func BenchmarkLabelSetStringMethod(b *testing.B) { - ls := make(LabelSet) - ls["monitor"] = "codelab" - ls["foo2"] = "bar" - ls["foo"] = "bar" - ls["abc"] = "prometheus" - ls["foo11"] = "bar11" - for i := 0; i < b.N; i++ { - _ = ls.String() - } -} diff --git a/model/labelset_string.go b/model/labelset_string.go index 481c47b4..abb2c900 100644 --- a/model/labelset_string.go +++ b/model/labelset_string.go @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build go1.21 - package model import ( diff --git a/model/labelset_string_go120.go b/model/labelset_string_go120.go deleted file mode 100644 index c4212685..00000000 --- a/model/labelset_string_go120.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2024 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 - -package model - -import ( - "fmt" - "sort" - "strings" -) - -// String was optimized using functions not available for go 1.20 -// or lower. We keep the old implementation for compatibility with client_golang. -// Once client golang drops support for go 1.20 (scheduled for August 2024), this -// file can be removed. -func (l LabelSet) String() string { - labelNames := make([]string, 0, len(l)) - for name := range l { - labelNames = append(labelNames, string(name)) - } - sort.Strings(labelNames) - lstrs := make([]string, 0, len(l)) - for _, name := range labelNames { - lstrs = append(lstrs, fmt.Sprintf("%s=%q", name, l[LabelName(name)])) - } - return fmt.Sprintf("{%s}", strings.Join(lstrs, ", ")) -} diff --git a/model/labelset_test.go b/model/labelset_test.go index 033dcf36..7334b0a0 100644 --- a/model/labelset_test.go +++ b/model/labelset_test.go @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build go1.21 - package model import ( diff --git a/promslog/flag/flag.go b/promslog/flag/flag.go index 34edb6ff..0a164fcc 100644 --- a/promslog/flag/flag.go +++ b/promslog/flag/flag.go @@ -15,8 +15,6 @@ // across Prometheus components. // It should typically only ever be imported by main packages. -//go:build go1.21 - package flag import ( diff --git a/promslog/slog.go b/promslog/slog.go index 31e003be..f77ce91e 100644 --- a/promslog/slog.go +++ b/promslog/slog.go @@ -15,8 +15,6 @@ // library's log/slog logger. // It should typically only ever be imported by main packages. -//go:build go1.21 - package promslog import ( diff --git a/promslog/slog_test.go b/promslog/slog_test.go index 69e3f6fc..ffc4ea4c 100644 --- a/promslog/slog_test.go +++ b/promslog/slog_test.go @@ -11,8 +11,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build go1.21 - package promslog import ( diff --git a/sigv4/go.mod b/sigv4/go.mod index 8f62c69d..0239df61 100644 --- a/sigv4/go.mod +++ b/sigv4/go.mod @@ -1,12 +1,12 @@ module github.com/prometheus/common/sigv4 -go 1.20 +go 1.21 replace github.com/prometheus/common => ../ require ( github.com/aws/aws-sdk-go v1.55.5 - github.com/prometheus/common v0.55.0 + github.com/prometheus/common v0.59.1 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -21,7 +21,7 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.20.0 // indirect + github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect golang.org/x/net v0.29.0 // indirect diff --git a/sigv4/go.sum b/sigv4/go.sum index 32698ad4..893285f1 100644 --- a/sigv4/go.sum +++ b/sigv4/go.sum @@ -9,6 +9,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -16,7 +17,9 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= @@ -25,13 +28,14 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= -github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -47,6 +51,7 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=