Skip to content

Commit

Permalink
Annotate request handler span with processed blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Mar 27, 2024
1 parent 87bebc0 commit a78c747
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 6 additions & 7 deletions pkg/bloomgateway/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"

"github.com/grafana/dskit/concurrency"
Expand Down Expand Up @@ -171,13 +172,11 @@ func (p *processor) processBlock(_ context.Context, blockQuerier *v1.BlockQuerie
iters := make([]v1.PeekingIterator[v1.Request], 0, len(tasks))

for _, task := range tasks {
// md, _ := blockQuerier.Metadata()
// blk := bloomshipper.BlockRefFrom(task.Tenant, task.table.String(), md)
//
// Why don't we get the span from the task context even though we create it
// at the beginning of the request handler?
// sp := opentracing.SpanFromContext(task.ctx)
// sp.LogKV("process block", blk.String())
if sp := opentracing.SpanFromContext(task.ctx); sp != nil {
md, _ := blockQuerier.Metadata()
blk := bloomshipper.BlockRefFrom(task.Tenant, task.table.String(), md)
sp.LogKV("process block", blk.String())
}

it := v1.NewPeekingIter(task.RequestIter(tokenizer))
iters = append(iters, it)
Expand Down
6 changes: 6 additions & 0 deletions pkg/bloomgateway/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/go-kit/log"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
Expand Down Expand Up @@ -88,6 +89,11 @@ func (s *dummyStore) FetchBlocks(_ context.Context, refs []bloomshipper.BlockRef

func TestProcessor(t *testing.T) {
ctx := context.Background()
// create a span for the request, because the processer annotates the span
// with the blocks that have been processed
sp, ctx := opentracing.StartSpanFromContext(ctx, "TestProcessor")
t.Cleanup(sp.Finish)

tenant := "fake"
now := mktime("2024-01-27 12:00")
metrics := newWorkerMetrics(prometheus.NewPedanticRegistry(), constants.Loki, "bloom_gatway")
Expand Down

0 comments on commit a78c747

Please sign in to comment.