Skip to content

Commit

Permalink
query: reuse our own gate (#6079)
Browse files Browse the repository at this point in the history
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 <giedrius.statkevicius@vinted.com>
  • Loading branch information
GiedriusS authored Jan 27, 2023
1 parent 30fd69d commit 431a6cf
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 431a6cf

Please sign in to comment.