Skip to content

Commit

Permalink
Use emptyPostingsCount in lazyRespSet
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed Nov 4, 2022
1 parent 16a7088 commit 11a8aa1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
2 changes: 2 additions & 0 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/thanos-community/promql-engine/engine"

apiv1 "github.com/thanos-io/thanos/pkg/api/query"
"github.com/thanos-io/thanos/pkg/compact/downsample"
"github.com/thanos-io/thanos/pkg/component"
Expand Down Expand Up @@ -97,6 +98,7 @@ func registerQuery(app *extkingpin.App) {

queryTimeout := extkingpin.ModelDuration(cmd.Flag("query.timeout", "Maximum time to process query by query node.").
Default("2m"))

promqlEngine := cmd.Flag("query.promql-engine", "PromQL engine to use.").Default(string(promqlEnginePrometheus)).Hidden().
Enum(string(promqlEnginePrometheus), string(promqlEngineThanos))

Expand Down
14 changes: 2 additions & 12 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ type bucketStoreMetrics struct {
queriesDropped *prometheus.CounterVec
seriesRefetches prometheus.Counter
emptyPostingCount prometheus.Counter
emptyStreamResponses prometheus.Counter

cachedPostingsCompressions *prometheus.CounterVec
cachedPostingsCompressionErrors *prometheus.CounterVec
Expand Down Expand Up @@ -282,11 +281,6 @@ func newBucketStoreMetrics(reg prometheus.Registerer) *bucketStoreMetrics {
Help: "Total number of empty postings when fetching block series.",
})

m.emptyStreamResponses = promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "thanos_bucket_store_empty_blocks_total",
Help: "Total number of queried blocks that have no matching series.",
})

return &m
}

Expand Down Expand Up @@ -885,15 +879,13 @@ func (b *blockSeriesClient) MergeStats(stats *queryStats) *queryStats {
func (b *blockSeriesClient) ExpandPostings(
matchers []*labels.Matcher,
seriesLimiter SeriesLimiter,
emptyPostingsCount prometheus.Counter,
) error {
ps, err := b.indexr.ExpandedPostings(b.ctx, matchers, b.bytesLimiter)
if err != nil {
return errors.Wrap(err, "expanded matching posting")
}

if len(ps) == 0 {
emptyPostingsCount.Inc()
return nil
}

Expand Down Expand Up @@ -1225,7 +1217,7 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
"block.resolution": blk.meta.Thanos.Downsample.Resolution,
})

if err := blockClient.ExpandPostings(blockMatchers, seriesLimiter, s.metrics.emptyPostingCount); err != nil {
if err := blockClient.ExpandPostings(blockMatchers, seriesLimiter); err != nil {
span.Finish()
return errors.Wrapf(err, "fetch series for block %s", blk.meta.ULID)
}
Expand All @@ -1244,7 +1236,7 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
blockClient,
shardMatcher,
false,
blk.metrics.emptyStreamResponses,
s.metrics.emptyPostingCount,
)

mtx.Lock()
Expand Down Expand Up @@ -1463,7 +1455,6 @@ func (s *BucketStore) LabelNames(ctx context.Context, req *storepb.LabelNamesReq
if err := blockClient.ExpandPostings(
reqSeriesMatchersNoExtLabels,
seriesLimiter,
s.metrics.emptyPostingCount,
); err != nil {
return err
}
Expand Down Expand Up @@ -1638,7 +1629,6 @@ func (s *BucketStore) LabelValues(ctx context.Context, req *storepb.LabelValuesR
if err := blockClient.ExpandPostings(
reqSeriesMatchersNoExtLabels,
seriesLimiter,
s.metrics.emptyPostingCount,
); err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/store/proxy_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ func newLazyRespSet(
shardMatcher *storepb.ShardMatcher,
applySharding bool,
emptyStreamResponses prometheus.Counter,

) respSet {
bufferedResponses := []*storepb.SeriesResponse{}
bufferedResponsesMtx := &sync.Mutex{}
Expand Down

0 comments on commit 11a8aa1

Please sign in to comment.