Skip to content

Commit 35f9611

Browse files
committed
Improving logs and adding some spans on the parquet queriable
Signed-off-by: alanprot <[email protected]>
1 parent a73deb4 commit 35f9611

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/querier/parquet_queryable.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/go-kit/log"
99
"github.com/go-kit/log/level"
1010
lru "github.com/hashicorp/golang-lru/v2"
11+
"github.com/opentracing/opentracing-go"
1112
"github.com/parquet-go/parquet-go"
1213
"github.com/pkg/errors"
1314
"github.com/prometheus-community/parquet-common/schema"
@@ -30,6 +31,7 @@ import (
3031
util_log "github.com/cortexproject/cortex/pkg/util/log"
3132
"github.com/cortexproject/cortex/pkg/util/multierror"
3233
"github.com/cortexproject/cortex/pkg/util/services"
34+
"github.com/cortexproject/cortex/pkg/util/spanlogger"
3335
"github.com/cortexproject/cortex/pkg/util/validation"
3436
)
3537

@@ -146,6 +148,9 @@ func NewParquetQueryable(
146148
shards := make([]*parquet_storage.ParquetShard, len(blocks))
147149
errGroup := &errgroup.Group{}
148150

151+
log, ctx := spanlogger.New(ctx, "parquetQuerierWithFallback.OpenShards")
152+
defer log.Span.Finish()
153+
149154
for i, block := range blocks {
150155
errGroup.Go(func() error {
151156
cacheKey := fmt.Sprintf("%v-%v", userID, block.ID)
@@ -165,7 +170,7 @@ func NewParquetQueryable(
165170
parquet_storage.WithOptimisticReader(true),
166171
)
167172
if err != nil {
168-
return err
173+
return errors.Wrapf(err, "failed to open parquet shard. block: %v", block.ID.String())
169174
}
170175
cache.Set(cacheKey, shard)
171176
}
@@ -266,6 +271,9 @@ type parquetQuerierWithFallback struct {
266271
}
267272

268273
func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
274+
log, ctx := spanlogger.New(ctx, "parquetQuerierWithFallback.LabelValues")
275+
defer log.Span.Finish()
276+
269277
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
270278
defer q.incrementOpsMetric("LabelValues", remaining, parquet)
271279
if err != nil {
@@ -312,6 +320,9 @@ func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name strin
312320
}
313321

314322
func (q *parquetQuerierWithFallback) LabelNames(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
323+
log, ctx := spanlogger.New(ctx, "parquetQuerierWithFallback.LabelNames")
324+
defer log.Span.Finish()
325+
315326
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
316327
defer q.incrementOpsMetric("LabelNames", remaining, parquet)
317328
if err != nil {
@@ -359,6 +370,9 @@ func (q *parquetQuerierWithFallback) LabelNames(ctx context.Context, hints *stor
359370
}
360371

361372
func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool, h *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet {
373+
log, ctx := spanlogger.New(ctx, "parquetQuerierWithFallback.Select")
374+
defer log.Span.Finish()
375+
362376
userID, err := tenant.TenantID(ctx)
363377
if err != nil {
364378
storage.ErrSeriesSet(err)
@@ -408,6 +422,8 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
408422
p := make(chan storage.SeriesSet, 1)
409423
promises = append(promises, p)
410424
go func() {
425+
span, _ := opentracing.StartSpanFromContext(ctx, "parquetQuerier.Select")
426+
defer span.Finish()
411427
p <- q.parquetQuerier.Select(InjectBlocksIntoContext(ctx, parquet...), sortSeries, &hints, matchers...)
412428
}()
413429
}

0 commit comments

Comments
 (0)