diff --git a/.golangci.yml b/.golangci.yml index d379b4db70..fec430cf08 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,10 +10,10 @@ linters: - depguard - errorlint - exptostd + - gci - gocritic - godot - gofumpt - - goimports - loggercheck - misspell - nilnesserr @@ -103,8 +103,11 @@ linters-settings: - (*net/http.Server).Shutdown # Never check for rollback errors as Rollback() is called when a previous error was detected. - (github.com/prometheus/prometheus/storage.Appender).Rollback - goimports: - local-prefixes: github.com/prometheus/prometheus + gci: + sections: + - standard + - default + - prefix(github.com/prometheus/prometheus) gofumpt: extra-rules: true perfsprint: diff --git a/cmd/promtool/analyze_test.go b/cmd/promtool/analyze_test.go index 1e16a22d35..3de4283a15 100644 --- a/cmd/promtool/analyze_test.go +++ b/cmd/promtool/analyze_test.go @@ -17,9 +17,8 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" ) var ( diff --git a/cmd/promtool/backfill.go b/cmd/promtool/backfill.go index 0964f0d546..47de3b5c1c 100644 --- a/cmd/promtool/backfill.go +++ b/cmd/promtool/backfill.go @@ -22,7 +22,6 @@ import ( "time" "github.com/oklog/ulid/v2" - "github.com/prometheus/common/promslog" "github.com/prometheus/prometheus/model/labels" diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index 5955cc0655..5fa4de44ed 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -36,6 +36,8 @@ import ( "github.com/prometheus/client_golang/api" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil/promlint" + dto "github.com/prometheus/client_model/go" + promconfig "github.com/prometheus/common/config" "github.com/prometheus/common/expfmt" "github.com/prometheus/common/model" "github.com/prometheus/common/promslog" @@ -43,9 +45,6 @@ import ( "github.com/prometheus/exporter-toolkit/web" "gopkg.in/yaml.v2" - dto "github.com/prometheus/client_model/go" - promconfig "github.com/prometheus/common/config" - "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/file" diff --git a/cmd/promtool/sd_test.go b/cmd/promtool/sd_test.go index 90318ba983..8f174a9b80 100644 --- a/cmd/promtool/sd_test.go +++ b/cmd/promtool/sd_test.go @@ -18,14 +18,13 @@ import ( "time" "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/relabel" "github.com/prometheus/prometheus/util/testutil" - - "github.com/stretchr/testify/require" ) func TestSDCheckResult(t *testing.T) { diff --git a/cmd/promtool/tsdb.go b/cmd/promtool/tsdb.go index 6a62e2e8bc..fe490bbeaf 100644 --- a/cmd/promtool/tsdb.go +++ b/cmd/promtool/tsdb.go @@ -33,9 +33,8 @@ import ( "time" "github.com/alecthomas/units" - "go.uber.org/atomic" - "github.com/prometheus/common/promslog" + "go.uber.org/atomic" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql/parser" diff --git a/cmd/promtool/unittest.go b/cmd/promtool/unittest.go index 06b0e28c51..7a97a466a6 100644 --- a/cmd/promtool/unittest.go +++ b/cmd/promtool/unittest.go @@ -29,10 +29,9 @@ import ( "github.com/google/go-cmp/cmp" "github.com/grafana/regexp" "github.com/nsf/jsondiff" - "gopkg.in/yaml.v2" - "github.com/prometheus/common/model" "github.com/prometheus/common/promslog" + "gopkg.in/yaml.v2" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" diff --git a/discovery/azure/azure.go b/discovery/azure/azure.go index 8a6945790f..670afb5a4e 100644 --- a/discovery/azure/azure.go +++ b/discovery/azure/azure.go @@ -38,9 +38,8 @@ import ( "github.com/Code-Hex/go-generics-cache/policy/lru" "github.com/prometheus/client_golang/prometheus" config_util "github.com/prometheus/common/config" - "github.com/prometheus/common/promslog" - "github.com/prometheus/common/model" + "github.com/prometheus/common/promslog" "github.com/prometheus/common/version" "github.com/prometheus/prometheus/discovery" diff --git a/discovery/kubernetes/kubernetes.go b/discovery/kubernetes/kubernetes.go index c6f0e445da..03d9f2f449 100644 --- a/discovery/kubernetes/kubernetes.go +++ b/discovery/kubernetes/kubernetes.go @@ -24,8 +24,6 @@ import ( "sync" "time" - "github.com/prometheus/prometheus/util/strutil" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/config" "github.com/prometheus/common/model" @@ -40,15 +38,15 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/kubernetes" + // Required to get the GCP auth provider working. + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/clientcmd" - // Required to get the GCP auth provider working. - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/targetgroup" + "github.com/prometheus/prometheus/util/strutil" ) const ( diff --git a/discovery/kubernetes/kubernetes_test.go b/discovery/kubernetes/kubernetes_test.go index 66c5d29ad7..fb53032845 100644 --- a/discovery/kubernetes/kubernetes_test.go +++ b/discovery/kubernetes/kubernetes_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + "github.com/prometheus/client_golang/prometheus" prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" "github.com/prometheus/common/promslog" "github.com/stretchr/testify/require" @@ -35,8 +36,6 @@ import ( kubetesting "k8s.io/client-go/testing" "k8s.io/client-go/tools/cache" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/util/testutil" diff --git a/discovery/ovhcloud/vps_test.go b/discovery/ovhcloud/vps_test.go index 00d59da7f0..d7a2a705c6 100644 --- a/discovery/ovhcloud/vps_test.go +++ b/discovery/ovhcloud/vps_test.go @@ -21,11 +21,10 @@ import ( "os" "testing" - yaml "gopkg.in/yaml.v2" - "github.com/prometheus/common/model" "github.com/prometheus/common/promslog" "github.com/stretchr/testify/require" + yaml "gopkg.in/yaml.v2" ) func TestOvhCloudVpsRefresh(t *testing.T) { diff --git a/discovery/registry.go b/discovery/registry.go index 2401d78fba..93b88ccfab 100644 --- a/discovery/registry.go +++ b/discovery/registry.go @@ -22,9 +22,8 @@ import ( "strings" "sync" - "gopkg.in/yaml.v2" - "github.com/prometheus/client_golang/prometheus" + "gopkg.in/yaml.v2" "github.com/prometheus/prometheus/discovery/targetgroup" ) diff --git a/discovery/uyuni/uyuni_test.go b/discovery/uyuni/uyuni_test.go index 40d92fe79c..46567587a8 100644 --- a/discovery/uyuni/uyuni_test.go +++ b/discovery/uyuni/uyuni_test.go @@ -21,9 +21,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/prometheus/client_golang/prometheus" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery/targetgroup" diff --git a/internal/tools/go.mod b/internal/tools/go.mod index 4445887371..f20608ad06 100644 --- a/internal/tools/go.mod +++ b/internal/tools/go.mod @@ -6,9 +6,9 @@ toolchain go1.23.4 require ( github.com/bufbuild/buf v1.50.1 + github.com/daixiang0/gci v0.13.5 github.com/gogo/protobuf v1.3.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 - golang.org/x/tools v0.31.0 ) require ( @@ -50,6 +50,7 @@ require ( github.com/google/go-containerregistry v0.20.3 // indirect github.com/google/pprof v0.0.0-20250302191652-9094ed2288e7 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/hexops/gotextdiff v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jdx/go-netrc v1.0.0 // indirect github.com/klauspost/compress v1.18.0 // indirect @@ -106,6 +107,7 @@ require ( golang.org/x/sys v0.31.0 // indirect golang.org/x/term v0.30.0 // indirect golang.org/x/text v0.23.0 // indirect + golang.org/x/tools v0.31.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect google.golang.org/grpc v1.70.0 // indirect diff --git a/internal/tools/go.sum b/internal/tools/go.sum index 9c3ec36732..ff273c1e9c 100644 --- a/internal/tools/go.sum +++ b/internal/tools/go.sum @@ -57,6 +57,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= +github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= @@ -112,6 +114,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 372e201566..e57e37186f 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -19,8 +19,8 @@ package tools import ( _ "github.com/bufbuild/buf/cmd/buf" + _ "github.com/daixiang0/gci/cmd/gci" _ "github.com/gogo/protobuf/protoc-gen-gogofast" _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" - _ "golang.org/x/tools/cmd/goimports" ) diff --git a/model/textparse/benchmark_test.go b/model/textparse/benchmark_test.go index 9abda92a26..c4a57ea650 100644 --- a/model/textparse/benchmark_test.go +++ b/model/textparse/benchmark_test.go @@ -23,12 +23,12 @@ import ( "strings" "testing" - "github.com/prometheus/prometheus/model/exemplar" - "github.com/prometheus/prometheus/model/labels" - "github.com/prometheus/common/expfmt" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" + + "github.com/prometheus/prometheus/model/exemplar" + "github.com/prometheus/prometheus/model/labels" ) // BenchmarkParse... set of benchmarks analyze efficiency of parsing various diff --git a/model/textparse/nhcbparse_test.go b/model/textparse/nhcbparse_test.go index 8a5aa117a9..68f2adf1b3 100644 --- a/model/textparse/nhcbparse_test.go +++ b/model/textparse/nhcbparse_test.go @@ -20,9 +20,8 @@ import ( "testing" "github.com/gogo/protobuf/proto" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/model/exemplar" "github.com/prometheus/prometheus/model/histogram" diff --git a/model/textparse/protobufparse.go b/model/textparse/protobufparse.go index 75c51d3e73..834e34133a 100644 --- a/model/textparse/protobufparse.go +++ b/model/textparse/protobufparse.go @@ -30,7 +30,6 @@ import ( "github.com/prometheus/prometheus/model/exemplar" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" - dto "github.com/prometheus/prometheus/prompb/io/prometheus/client" ) diff --git a/notifier/notifier_test.go b/notifier/notifier_test.go index 7d63e4047b..d9ba1ca9ab 100644 --- a/notifier/notifier_test.go +++ b/notifier/notifier_test.go @@ -35,9 +35,8 @@ import ( "go.uber.org/atomic" "gopkg.in/yaml.v2" - "github.com/prometheus/prometheus/discovery" - "github.com/prometheus/prometheus/config" + "github.com/prometheus/prometheus/discovery" _ "github.com/prometheus/prometheus/discovery/file" "github.com/prometheus/prometheus/discovery/targetgroup" "github.com/prometheus/prometheus/model/labels" diff --git a/plugins/generate.go b/plugins/generate.go index 3db6de4ab0..09a1515a18 100644 --- a/plugins/generate.go +++ b/plugins/generate.go @@ -57,7 +57,7 @@ func main() { // See the License for the specific language governing permissions and // limitations under the License. -// This file is generated by "make plugins". +// Code generated by "make plugins". DO NOT EDIT. package plugins @@ -75,7 +75,7 @@ package plugins log.Fatal(err) } - for i, plugin := range plugins { + for _, plugin := range plugins { _, err = f.WriteString(fmt.Sprintf("\t// Register %s plugin.\n", path.Base(plugin))) if err != nil { log.Fatal(err) @@ -84,12 +84,6 @@ package plugins if err != nil { log.Fatal(err) } - if i < len(plugins)-1 { - _, err = f.WriteString("\n") - if err != nil { - log.Fatal(err) - } - } } _, err = f.WriteString(")\n") diff --git a/plugins/plugins.go b/plugins/plugins.go index e6994e2068..15379d4705 100644 --- a/plugins/plugins.go +++ b/plugins/plugins.go @@ -11,77 +11,55 @@ // See the License for the specific language governing permissions and // limitations under the License. -// This file is generated by "make plugins". +// Code generated by "make plugins". DO NOT EDIT. package plugins import ( // Register aws plugin. _ "github.com/prometheus/prometheus/discovery/aws" - // Register azure plugin. _ "github.com/prometheus/prometheus/discovery/azure" - // Register consul plugin. _ "github.com/prometheus/prometheus/discovery/consul" - // Register digitalocean plugin. _ "github.com/prometheus/prometheus/discovery/digitalocean" - // Register dns plugin. _ "github.com/prometheus/prometheus/discovery/dns" - // Register eureka plugin. _ "github.com/prometheus/prometheus/discovery/eureka" - // Register gce plugin. _ "github.com/prometheus/prometheus/discovery/gce" - // Register hetzner plugin. _ "github.com/prometheus/prometheus/discovery/hetzner" - // Register ionos plugin. _ "github.com/prometheus/prometheus/discovery/ionos" - // Register kubernetes plugin. _ "github.com/prometheus/prometheus/discovery/kubernetes" - // Register linode plugin. _ "github.com/prometheus/prometheus/discovery/linode" - // Register marathon plugin. _ "github.com/prometheus/prometheus/discovery/marathon" - // Register moby plugin. _ "github.com/prometheus/prometheus/discovery/moby" - // Register nomad plugin. _ "github.com/prometheus/prometheus/discovery/nomad" - // Register openstack plugin. _ "github.com/prometheus/prometheus/discovery/openstack" - // Register ovhcloud plugin. _ "github.com/prometheus/prometheus/discovery/ovhcloud" - // Register puppetdb plugin. _ "github.com/prometheus/prometheus/discovery/puppetdb" - // Register scaleway plugin. _ "github.com/prometheus/prometheus/discovery/scaleway" - // Register triton plugin. _ "github.com/prometheus/prometheus/discovery/triton" - // Register uyuni plugin. _ "github.com/prometheus/prometheus/discovery/uyuni" - // Register vultr plugin. _ "github.com/prometheus/prometheus/discovery/vultr" - // Register xds plugin. _ "github.com/prometheus/prometheus/discovery/xds" - // Register zookeeper plugin. _ "github.com/prometheus/prometheus/discovery/zookeeper" ) diff --git a/prompb/io/prometheus/write/v2/types.pb.go b/prompb/io/prometheus/write/v2/types.pb.go index 3420d20e25..1419de217e 100644 --- a/prompb/io/prometheus/write/v2/types.pb.go +++ b/prompb/io/prometheus/write/v2/types.pb.go @@ -6,11 +6,12 @@ package writev2 import ( encoding_binary "encoding/binary" fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/promql/engine_internal_test.go b/promql/engine_internal_test.go index 0962c218c7..f873b6fabd 100644 --- a/promql/engine_internal_test.go +++ b/promql/engine_internal_test.go @@ -18,9 +18,8 @@ import ( "errors" "testing" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/promslog" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/promql/parser" "github.com/prometheus/prometheus/util/annotations" diff --git a/promql/parser/ast.go b/promql/parser/ast.go index 132ef3f0d2..a9f41978e0 100644 --- a/promql/parser/ast.go +++ b/promql/parser/ast.go @@ -19,9 +19,8 @@ import ( "time" "github.com/prometheus/prometheus/model/labels" - "github.com/prometheus/prometheus/storage" - "github.com/prometheus/prometheus/promql/parser/posrange" + "github.com/prometheus/prometheus/storage" ) // Node is a generic interface for all nodes in an AST. diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index 7a4f95d3ab..64ce97304c 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -26,9 +26,8 @@ import ( "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" - "github.com/prometheus/prometheus/util/testutil" - "github.com/prometheus/prometheus/promql/parser/posrange" + "github.com/prometheus/prometheus/util/testutil" ) var testExpr = []struct { diff --git a/rules/group.go b/rules/group.go index c9f5162cda..63391bc7a1 100644 --- a/rules/group.go +++ b/rules/group.go @@ -23,21 +23,19 @@ import ( "sync" "time" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/model" + "github.com/prometheus/common/promslog" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.uber.org/atomic" - "github.com/prometheus/prometheus/promql/parser" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" - "github.com/prometheus/common/promslog" - "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/timestamp" "github.com/prometheus/prometheus/model/value" "github.com/prometheus/prometheus/promql" + "github.com/prometheus/prometheus/promql/parser" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunkenc" ) diff --git a/rules/origin_test.go b/rules/origin_test.go index b38f5d99b2..717055ef85 100644 --- a/rules/origin_test.go +++ b/rules/origin_test.go @@ -19,9 +19,8 @@ import ( "testing" "time" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/promslog" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/promql" diff --git a/scrape/clientprotobuf.go b/scrape/clientprotobuf.go index e632035b40..6dc22c959f 100644 --- a/scrape/clientprotobuf.go +++ b/scrape/clientprotobuf.go @@ -18,7 +18,6 @@ import ( "encoding/binary" "github.com/gogo/protobuf/proto" - // Intentionally using client model to simulate client in tests. dto "github.com/prometheus/client_model/go" ) diff --git a/scrape/manager_test.go b/scrape/manager_test.go index d15b3edcec..df19dd5a83 100644 --- a/scrape/manager_test.go +++ b/scrape/manager_test.go @@ -40,10 +40,6 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "gopkg.in/yaml.v2" - "github.com/prometheus/prometheus/storage" - - "github.com/prometheus/prometheus/model/timestamp" - "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/discovery" _ "github.com/prometheus/prometheus/discovery/file" @@ -51,6 +47,8 @@ import ( "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/relabel" + "github.com/prometheus/prometheus/model/timestamp" + "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/tsdbutil" "github.com/prometheus/prometheus/util/runutil" "github.com/prometheus/prometheus/util/testutil" diff --git a/scripts/genproto.sh b/scripts/genproto.sh index acd650d780..03e9a96634 100755 --- a/scripts/genproto.sh +++ b/scripts/genproto.sh @@ -11,7 +11,7 @@ if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then fi pushd "internal/tools" -INSTALL_PKGS="github.com/bufbuild/buf/cmd/buf github.com/gogo/protobuf/protoc-gen-gogofast github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 golang.org/x/tools/cmd/goimports" +INSTALL_PKGS="github.com/bufbuild/buf/cmd/buf github.com/daixiang0/gci github.com/gogo/protobuf/protoc-gen-gogofast github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" for pkg in ${INSTALL_PKGS}; do GO111MODULE=on go install "$pkg" done @@ -29,6 +29,7 @@ for dir in ${DIRS}; do sed -i.bak -E 's/golang\/protobuf\/descriptor/gogo\/protobuf\/protoc-gen-gogo\/descriptor/g' *.go sed -i.bak -E 's/golang\/protobuf/gogo\/protobuf/g' *.go rm -f -- *.bak - goimports -w ./*.go ./io/prometheus/client/*.go + gci write -s standard -s default -s "prefix(github.com/prometheus/prometheus)" . popd done + diff --git a/storage/remote/azuread/azuread.go b/storage/remote/azuread/azuread.go index aa3dee6b45..f06b57c8c4 100644 --- a/storage/remote/azuread/azuread.go +++ b/storage/remote/azuread/azuread.go @@ -21,13 +21,12 @@ import ( "sync" "time" - "github.com/grafana/regexp" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/google/uuid" + "github.com/grafana/regexp" ) // Clouds. diff --git a/storage/remote/otlptranslator/prometheusremotewrite/helper_test.go b/storage/remote/otlptranslator/prometheusremotewrite/helper_test.go index ea5a3fce57..bc12934091 100644 --- a/storage/remote/otlptranslator/prometheusremotewrite/helper_test.go +++ b/storage/remote/otlptranslator/prometheusremotewrite/helper_test.go @@ -21,11 +21,10 @@ import ( "testing" "time" - "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/pmetric" - "github.com/prometheus/common/model" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" "github.com/prometheus/prometheus/prompb" ) diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go index 785700f091..5421edb517 100644 --- a/storage/remote/queue_manager_test.go +++ b/storage/remote/queue_manager_test.go @@ -38,8 +38,6 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/atomic" - "github.com/prometheus/prometheus/util/compression" - "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" @@ -51,6 +49,7 @@ import ( "github.com/prometheus/prometheus/tsdb/chunks" "github.com/prometheus/prometheus/tsdb/record" "github.com/prometheus/prometheus/tsdb/wlog" + "github.com/prometheus/prometheus/util/compression" "github.com/prometheus/prometheus/util/runutil" "github.com/prometheus/prometheus/util/testutil" ) diff --git a/storage/remote/write_handler.go b/storage/remote/write_handler.go index a682b95c31..cbd4225d08 100644 --- a/storage/remote/write_handler.go +++ b/storage/remote/write_handler.go @@ -24,11 +24,15 @@ import ( "time" "github.com/gogo/protobuf/proto" + deltatocumulative "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/common/model" - - "github.com/prometheus/prometheus/util/compression" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/processor" + "go.opentelemetry.io/otel/metric/noop" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/exemplar" @@ -39,13 +43,7 @@ import ( writev2 "github.com/prometheus/prometheus/prompb/io/prometheus/write/v2" "github.com/prometheus/prometheus/storage" otlptranslator "github.com/prometheus/prometheus/storage/remote/otlptranslator/prometheusremotewrite" - - deltatocumulative "github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/consumer" - "go.opentelemetry.io/collector/pdata/pmetric" - "go.opentelemetry.io/collector/processor" - "go.opentelemetry.io/otel/metric/noop" + "github.com/prometheus/prometheus/util/compression" ) type writeHandler struct { diff --git a/storage/remote/write_handler_test.go b/storage/remote/write_handler_test.go index 492a1c82a0..e92d24f66e 100644 --- a/storage/remote/write_handler_test.go +++ b/storage/remote/write_handler_test.go @@ -29,11 +29,8 @@ import ( "github.com/gogo/protobuf/proto" "github.com/google/go-cmp/cmp" - "github.com/stretchr/testify/require" - - "github.com/prometheus/prometheus/util/compression" - "github.com/prometheus/common/promslog" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/exemplar" @@ -44,6 +41,7 @@ import ( writev2 "github.com/prometheus/prometheus/prompb/io/prometheus/write/v2" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb" + "github.com/prometheus/prometheus/util/compression" "github.com/prometheus/prometheus/util/testutil" ) diff --git a/template/template.go b/template/template.go index 25b65eb577..75a9f33bd2 100644 --- a/template/template.go +++ b/template/template.go @@ -29,12 +29,11 @@ import ( "github.com/grafana/regexp" "github.com/prometheus/client_golang/prometheus" + common_templates "github.com/prometheus/common/helpers/templates" "github.com/prometheus/common/model" "golang.org/x/text/cases" "golang.org/x/text/language" - common_templates "github.com/prometheus/common/helpers/templates" - "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/util/strutil" ) diff --git a/tsdb/block.go b/tsdb/block.go index da7fbf0c34..7f7d993800 100644 --- a/tsdb/block.go +++ b/tsdb/block.go @@ -27,7 +27,6 @@ import ( "sync" "github.com/oklog/ulid/v2" - "github.com/prometheus/common/promslog" "github.com/prometheus/prometheus/model/labels" diff --git a/tsdb/blockwriter_test.go b/tsdb/blockwriter_test.go index 2704b53566..e7c3146247 100644 --- a/tsdb/blockwriter_test.go +++ b/tsdb/blockwriter_test.go @@ -19,9 +19,8 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/promslog" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/tsdb/chunks" diff --git a/tsdb/head.go b/tsdb/head.go index 08bac79ca1..a9d4220cbd 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -27,10 +27,9 @@ import ( "time" "github.com/oklog/ulid/v2" - "go.uber.org/atomic" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/promslog" + "go.uber.org/atomic" "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/exemplar" diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 8791707273..8cd44db841 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -38,8 +38,6 @@ import ( "go.uber.org/atomic" "golang.org/x/sync/errgroup" - "github.com/prometheus/prometheus/util/compression" - "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/model/exemplar" "github.com/prometheus/prometheus/model/histogram" @@ -54,6 +52,7 @@ import ( "github.com/prometheus/prometheus/tsdb/tombstones" "github.com/prometheus/prometheus/tsdb/tsdbutil" "github.com/prometheus/prometheus/tsdb/wlog" + "github.com/prometheus/prometheus/util/compression" "github.com/prometheus/prometheus/util/testutil" ) diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index 51a2cb5ee8..3450eb9b87 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -25,9 +25,8 @@ import ( "sync" "time" - "go.uber.org/atomic" - "github.com/prometheus/client_golang/prometheus" + "go.uber.org/atomic" "github.com/prometheus/prometheus/model/exemplar" "github.com/prometheus/prometheus/model/histogram" diff --git a/tsdb/ooo_head_test.go b/tsdb/ooo_head_test.go index 203330fcd8..07467479dc 100644 --- a/tsdb/ooo_head_test.go +++ b/tsdb/ooo_head_test.go @@ -17,12 +17,12 @@ import ( "math" "testing" + "github.com/stretchr/testify/require" + "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/prometheus/prometheus/tsdb/tsdbutil" - - "github.com/stretchr/testify/require" ) const testMaxSize int = 32 diff --git a/tsdb/querier_bench_test.go b/tsdb/querier_bench_test.go index 038052e340..f5cc62d961 100644 --- a/tsdb/querier_bench_test.go +++ b/tsdb/querier_bench_test.go @@ -19,11 +19,11 @@ import ( "strconv" "testing" + "github.com/stretchr/testify/require" + "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/index" - - "github.com/stretchr/testify/require" ) // Make entries ~50B in size, to emulate real-world high cardinality. diff --git a/tsdb/record/record_test.go b/tsdb/record/record_test.go index 3785663643..6734f907f0 100644 --- a/tsdb/record/record_test.go +++ b/tsdb/record/record_test.go @@ -19,9 +19,8 @@ import ( "math/rand" "testing" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" diff --git a/tsdb/testutil.go b/tsdb/testutil.go index e957b0307b..4dac8c29ff 100644 --- a/tsdb/testutil.go +++ b/tsdb/testutil.go @@ -16,16 +16,14 @@ package tsdb import ( "testing" - "github.com/prometheus/prometheus/tsdb/tsdbutil" - prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" - "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/tsdb/chunks" + "github.com/prometheus/prometheus/tsdb/tsdbutil" ) const ( diff --git a/tsdb/tombstones/tombstones_test.go b/tsdb/tombstones/tombstones_test.go index cbf686e4bb..9b5093b261 100644 --- a/tsdb/tombstones/tombstones_test.go +++ b/tsdb/tombstones/tombstones_test.go @@ -20,11 +20,10 @@ import ( "testing" "time" + "github.com/prometheus/common/promslog" "github.com/stretchr/testify/require" "go.uber.org/goleak" - "github.com/prometheus/common/promslog" - "github.com/prometheus/prometheus/storage" ) diff --git a/tsdb/tsdbutil/dir_locker_test.go b/tsdb/tsdbutil/dir_locker_test.go index 65e2761692..8c027415d3 100644 --- a/tsdb/tsdbutil/dir_locker_test.go +++ b/tsdb/tsdbutil/dir_locker_test.go @@ -16,9 +16,8 @@ package tsdbutil import ( "testing" - "github.com/stretchr/testify/require" - "github.com/prometheus/common/promslog" + "github.com/stretchr/testify/require" "github.com/prometheus/prometheus/util/testutil" ) diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 79026037c6..254ce074ce 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -30,10 +30,6 @@ import ( "testing" "time" - "github.com/prometheus/prometheus/prompb" - "github.com/prometheus/prometheus/util/stats" - "github.com/prometheus/prometheus/util/testutil" - jsoniter "github.com/json-iterator/go" "github.com/prometheus/client_golang/prometheus" config_util "github.com/prometheus/common/config" @@ -47,6 +43,7 @@ import ( "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/metadata" "github.com/prometheus/prometheus/model/timestamp" + "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql/parser" "github.com/prometheus/prometheus/promql/promqltest" @@ -55,7 +52,9 @@ import ( "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage/remote" "github.com/prometheus/prometheus/tsdb" + "github.com/prometheus/prometheus/util/stats" "github.com/prometheus/prometheus/util/teststorage" + "github.com/prometheus/prometheus/util/testutil" ) func testEngine(t *testing.T) *promql.Engine {