Skip to content

Commit 3c523e4

Browse files
committed
rename metric
Signed-off-by: alanprot <[email protected]>
1 parent 72cad80 commit 3c523e4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pkg/querier/parquet_queryable.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func getBlockStoreType(ctx context.Context, defaultBlockStoreType blockStoreType
6868

6969
type parquetQueryableFallbackMetrics struct {
7070
blocksQueriedTotal *prometheus.CounterVec
71-
selectCount *prometheus.CounterVec
71+
operationsTotal *prometheus.CounterVec
7272
}
7373

7474
func newParquetQueryableFallbackMetrics(reg prometheus.Registerer) *parquetQueryableFallbackMetrics {
@@ -77,10 +77,10 @@ func newParquetQueryableFallbackMetrics(reg prometheus.Registerer) *parquetQuery
7777
Name: "cortex_parquet_queryable_blocks_queried_total",
7878
Help: "Total number of blocks found to query.",
7979
}, []string{"type"}),
80-
selectCount: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
81-
Name: "cortex_parquet_queryable_selects_queried_total",
82-
Help: "Total number of selects.",
83-
}, []string{"type"}),
80+
operationsTotal: promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
81+
Name: "cortex_parquet_queryable_operation_total",
82+
Help: "Total number of Operations.",
83+
}, []string{"type", "method"}),
8484
}
8585
}
8686

@@ -267,6 +267,7 @@ type parquetQuerierWithFallback struct {
267267

268268
func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
269269
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
270+
defer q.incrementOpsMetric("LabelValues", remaining, parquet)
270271
if err != nil {
271272
return nil, nil, err
272273
}
@@ -312,6 +313,7 @@ func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name strin
312313

313314
func (q *parquetQuerierWithFallback) LabelNames(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
314315
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
316+
defer q.incrementOpsMetric("LabelNames", remaining, parquet)
315317
if err != nil {
316318
return nil, nil, err
317319
}
@@ -389,6 +391,8 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
389391
}
390392

391393
remaining, parquet, err := q.getBlocks(ctx, mint, maxt)
394+
defer q.incrementOpsMetric("Select", remaining, parquet)
395+
392396
if err != nil {
393397
return storage.ErrSeriesSet(err)
394398
}
@@ -477,17 +481,18 @@ func (q *parquetQuerierWithFallback) getBlocks(ctx context.Context, minT, maxT i
477481

478482
q.metrics.blocksQueriedTotal.WithLabelValues("parquet").Add(float64(len(parquetBlocks)))
479483
q.metrics.blocksQueriedTotal.WithLabelValues("tsdb").Add(float64(len(remaining)))
484+
return remaining, parquetBlocks, nil
485+
}
480486

487+
func (q *parquetQuerierWithFallback) incrementOpsMetric(method string, remaining []*bucketindex.Block, parquetBlocks []*bucketindex.Block) {
481488
switch {
482489
case len(remaining) > 0 && len(parquetBlocks) > 0:
483-
q.metrics.selectCount.WithLabelValues("mixed").Inc()
490+
q.metrics.operationsTotal.WithLabelValues("mixed", method).Inc()
484491
case len(remaining) > 0 && len(parquetBlocks) == 0:
485-
q.metrics.selectCount.WithLabelValues("tsdb").Inc()
492+
q.metrics.operationsTotal.WithLabelValues("tsdb", method).Inc()
486493
case len(remaining) == 0 && len(parquetBlocks) > 0:
487-
q.metrics.selectCount.WithLabelValues("parquet").Inc()
494+
q.metrics.operationsTotal.WithLabelValues("parquet", method).Inc()
488495
}
489-
490-
return remaining, parquetBlocks, nil
491496
}
492497

493498
type cacheInterface[T any] interface {

0 commit comments

Comments
 (0)