Skip to content

Commit 8ad8c44

Browse files
authored
Improving logs and adding some spans on the parquet queryable (#6806)
* Improving logs and adding some spans on the parquet queriable Signed-off-by: alanprot <[email protected]> * lint Signed-off-by: alanprot <[email protected]> * comments Signed-off-by: alanprot <[email protected]> --------- Signed-off-by: alanprot <[email protected]>
1 parent a73deb4 commit 8ad8c44

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

pkg/querier/parquet_queryable.go

Lines changed: 17 additions & 2 deletions
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"
@@ -146,14 +147,17 @@ func NewParquetQueryable(
146147
shards := make([]*parquet_storage.ParquetShard, len(blocks))
147148
errGroup := &errgroup.Group{}
148149

150+
span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.OpenShards")
151+
defer span.Finish()
152+
149153
for i, block := range blocks {
150154
errGroup.Go(func() error {
151155
cacheKey := fmt.Sprintf("%v-%v", userID, block.ID)
152156
shard := cache.Get(cacheKey)
153157
if shard == nil {
154158
// we always only have 1 shard - shard 0
155159
// Use context.Background() here as the file can be cached and live after the request ends.
156-
shard, err = parquet_storage.OpenParquetShard(context.Background(),
160+
shard, err = parquet_storage.OpenParquetShard(context.WithoutCancel(ctx),
157161
userBkt,
158162
block.ID.String(),
159163
0,
@@ -165,7 +169,7 @@ func NewParquetQueryable(
165169
parquet_storage.WithOptimisticReader(true),
166170
)
167171
if err != nil {
168-
return err
172+
return errors.Wrapf(err, "failed to open parquet shard. block: %v", block.ID.String())
169173
}
170174
cache.Set(cacheKey, shard)
171175
}
@@ -266,6 +270,9 @@ type parquetQuerierWithFallback struct {
266270
}
267271

268272
func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
273+
span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.LabelValues")
274+
defer span.Finish()
275+
269276
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
270277
defer q.incrementOpsMetric("LabelValues", remaining, parquet)
271278
if err != nil {
@@ -312,6 +319,9 @@ func (q *parquetQuerierWithFallback) LabelValues(ctx context.Context, name strin
312319
}
313320

314321
func (q *parquetQuerierWithFallback) LabelNames(ctx context.Context, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {
322+
span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.LabelNames")
323+
defer span.Finish()
324+
315325
remaining, parquet, err := q.getBlocks(ctx, q.minT, q.maxT)
316326
defer q.incrementOpsMetric("LabelNames", remaining, parquet)
317327
if err != nil {
@@ -359,6 +369,9 @@ func (q *parquetQuerierWithFallback) LabelNames(ctx context.Context, hints *stor
359369
}
360370

361371
func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool, h *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet {
372+
span, ctx := opentracing.StartSpanFromContext(ctx, "parquetQuerierWithFallback.Select")
373+
defer span.Finish()
374+
362375
userID, err := tenant.TenantID(ctx)
363376
if err != nil {
364377
storage.ErrSeriesSet(err)
@@ -408,6 +421,8 @@ func (q *parquetQuerierWithFallback) Select(ctx context.Context, sortSeries bool
408421
p := make(chan storage.SeriesSet, 1)
409422
promises = append(promises, p)
410423
go func() {
424+
span, _ := opentracing.StartSpanFromContext(ctx, "parquetQuerier.Select")
425+
defer span.Finish()
411426
p <- q.parquetQuerier.Select(InjectBlocksIntoContext(ctx, parquet...), sortSeries, &hints, matchers...)
412427
}()
413428
}

0 commit comments

Comments
 (0)