From 61a877417e068458ffb126e541ab4f65539644de Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Mon, 25 Nov 2024 16:08:55 +0200 Subject: [PATCH] shards: log to trace on shardedSearcher.Search This logging is useful since we directly call this search (and avoid typeRepoSearcher) when evaluating List calls for type:repo searches. By adding in this logging we can understand the performance of potentially expensive queries here. --- shards/shards.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shards/shards.go b/shards/shards.go index 44e03aec..0991c582 100644 --- a/shards/shards.go +++ b/shards/shards.go @@ -514,7 +514,17 @@ func doSelectRepoSet(shards []*rankedShard, and *query.And) ([]*rankedShard, que func (ss *shardedSearcher) Search(ctx context.Context, q query.Q, opts *zoekt.SearchOptions) (sr *zoekt.SearchResult, err error) { tr, ctx := trace.New(ctx, "shardedSearcher.Search", "") + tr.LazyLog(q, true) + tr.LazyPrintf("opts: %+v", opts) defer func() { + if sr != nil { + tr.LazyPrintf("num files: %d", len(sr.Files)) + tr.LazyPrintf("stats: %+v", sr.Stats) + } + if err != nil { + tr.LazyPrintf("error: %v", err) + tr.SetError(err) + } tr.Finish() }() ctx, cancel := context.WithCancel(ctx)