fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

shards: always aggregate stats for tracing (#729)

Many a time I have seen a slow search without tracing turned on. I then
go to visit the net/trace page to see what happened but it is missing
the stats to try work out why.

This commit will ensure we always log the aggregated statistics. This
should be cheap to do given Add is relatively fast and LazyPrintf will
only do the stringer operation if someone loads the debug page. It does
mean a Stats object lives a bit longer in memory, but it is small.

Test Plan: go test

+5 -10
+5 -10
shards/eval.go
··· 44 44 tr, ctx := trace.New(ctx, "typeRepoSearcher.StreamSearch", "") 45 45 tr.LazyLog(q, true) 46 46 tr.LazyPrintf("opts: %+v", opts) 47 - var stats *zoekt.Stats 47 + var stats zoekt.Stats 48 48 defer func() { 49 49 tr.LazyPrintf("stats: %+v", stats) 50 50 if err != nil { ··· 59 59 return err 60 60 } 61 61 62 - if opts.Trace { 63 - stats = &zoekt.Stats{} 64 - return s.Streamer.StreamSearch(ctx, q, opts, stream.SenderFunc(func(event *zoekt.SearchResult) { 65 - stats.Add(event.Stats) 66 - sender.Send(event) 67 - })) 68 - } 69 - 70 - return s.Streamer.StreamSearch(ctx, q, opts, sender) 62 + return s.Streamer.StreamSearch(ctx, q, opts, stream.SenderFunc(func(event *zoekt.SearchResult) { 63 + stats.Add(event.Stats) 64 + sender.Send(event) 65 + })) 71 66 } 72 67 73 68 func (s *typeRepoSearcher) List(ctx context.Context, q query.Q, opts *zoekt.ListOptions) (rl *zoekt.RepoList, err error) {