From 4a718a32271fde873ecc55fa45aa4955c902d449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Thu, 4 May 2023 12:36:23 +0300 Subject: [PATCH] *: remove unmaintained gzip library (#6332) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch from nytimes gzip library to the klaustpost's gzip code. The old gzip HTTP handler shows up a lot in allocs so that's how I ended up doing this change. Signed-off-by: Giedrius Statkevičius --- Makefile | 1 + cmd/thanos/query_frontend.go | 6 +++--- go.mod | 1 - go.sum | 2 -- pkg/api/api.go | 4 ++-- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c80862ebcd..986503f1e0 100644 --- a/Makefile +++ b/Makefile @@ -395,6 +395,7 @@ github.com/prometheus/client_golang/prometheus.{DefaultGatherer,DefBuckets,NewUn github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,\ NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,\ NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec},\ +github.com/NYTimes/gziphandler.{GzipHandler}=github.com/klauspost/compress/gzhttp.{GzipHandler},\ sync/atomic=go.uber.org/atomic,github.com/cortexproject/cortex=github.com/thanos-io/thanos/internal/cortex,\ io/ioutil.{Discard,NopCloser,ReadAll,ReadDir,ReadFile,TempDir,TempFile,Writefile}" $(shell go list ./... | grep -v "internal/cortex") @$(FAILLINT) -paths "fmt.{Print,Println,Sprint}" -ignore-tests ./... diff --git a/cmd/thanos/query_frontend.go b/cmd/thanos/query_frontend.go index df7f2707bc..f3d2b1a9f7 100644 --- a/cmd/thanos/query_frontend.go +++ b/cmd/thanos/query_frontend.go @@ -8,10 +8,10 @@ import ( "net/http" "time" - "github.com/NYTimes/gziphandler" extflag "github.com/efficientgo/tools/extkingpin" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/klauspost/compress/gzhttp" "github.com/oklog/run" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" @@ -277,7 +277,7 @@ func runQueryFrontend( // Create the query frontend transport. handler := transport.NewHandler(*cfg.CortexHandlerConfig, roundTripper, logger, nil) if cfg.CompressResponses { - handler = gziphandler.GzipHandler(handler) + handler = gzhttp.GzipHandler(handler) } httpProbe := prober.NewHTTP() @@ -311,7 +311,7 @@ func runQueryFrontend( logger, ins.NewHandler( name, - gziphandler.GzipHandler( + gzhttp.GzipHandler( middleware.RequestID( logMiddleware.HTTPMiddleware(name, f), ), diff --git a/go.mod b/go.mod index 8b69966d6d..650d4e342c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( cloud.google.com/go/storage v1.28.1 // indirect cloud.google.com/go/trace v1.8.0 github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v1.8.3 - github.com/NYTimes/gziphandler v1.1.1 github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 github.com/alicebob/miniredis/v2 v2.22.0 github.com/blang/semver/v4 v4.0.0 diff --git a/go.sum b/go.sum index 33c196a42e..9919e51a41 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,6 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= -github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= -github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.6 h1:U68crOE3y3MPttCMQGywZOLrTeF5HHJ3/vDBCJn9/bA= github.com/OneOfOne/xxhash v1.2.6/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= diff --git a/pkg/api/api.go b/pkg/api/api.go index 3b5470f072..6be81c8b15 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -27,9 +27,9 @@ import ( "runtime" "time" - "github.com/NYTimes/gziphandler" "github.com/go-kit/log" "github.com/go-kit/log/level" + "github.com/klauspost/compress/gzhttp" "github.com/opentracing/opentracing-go" "github.com/prometheus/common/route" "github.com/prometheus/common/version" @@ -222,7 +222,7 @@ func GetInstr( return tracing.HTTPMiddleware(tracer, name, logger, ins.NewHandler(name, - gziphandler.GzipHandler( + gzhttp.GzipHandler( middleware.RequestID( logMiddleware.HTTPMiddleware(name, hf), ),