From 9ee957553444abe6955ec72c54673e942b5a1bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giedrius=20Statkevi=C4=8Dius?= Date: Fri, 27 Jan 2023 20:20:12 +0200 Subject: [PATCH] query: reuse our own gate (#6079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not call promgate directly but rather use our own wrapper that does everything we want - duration histogram, current in-flight calls, total calls. Signed-off-by: Giedrius Statkevičius --- pkg/query/querier.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/query/querier.go b/pkg/query/querier.go index 9fe4b96eca3..e0eeab489f9 100644 --- a/pkg/query/querier.go +++ b/pkg/query/querier.go @@ -14,11 +14,9 @@ import ( "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" - promgate "github.com/prometheus/prometheus/util/gate" "github.com/thanos-io/thanos/pkg/dedup" "github.com/thanos-io/thanos/pkg/extprom" @@ -68,10 +66,6 @@ func NewQueryableCreator( maxConcurrentSelects int, selectTimeout time.Duration, ) QueryableCreator { - duration := promauto.With( - extprom.WrapRegistererWithPrefix("concurrent_selects_", reg), - ).NewHistogram(gate.DurationHistogramOpts) - return func( deduplicate bool, replicaLabels []string, @@ -83,6 +77,7 @@ func NewQueryableCreator( shardInfo *storepb.ShardInfo, seriesStatsReporter seriesStatsReporter, ) storage.Queryable { + reg = extprom.WrapRegistererWithPrefix("concurrent_selects_", reg) return &queryable{ logger: logger, replicaLabels: replicaLabels, @@ -93,7 +88,7 @@ func NewQueryableCreator( partialResponse: partialResponse, skipChunks: skipChunks, gateProviderFn: func() gate.Gate { - return gate.InstrumentGateDuration(duration, promgate.New(maxConcurrentSelects)) + return gate.New(reg, maxConcurrentSelects) }, maxConcurrentSelects: maxConcurrentSelects, selectTimeout: selectTimeout,