Skip to content

Commit

Permalink
all: observe missing Stats RegexpsConsidered and FlushReason
Browse files Browse the repository at this point in the history
Noticed we didn't include these fields in our prometheus and logging
integration.

Test Plan: go test ./...
  • Loading branch information
keegancsmith committed Jul 10, 2023
1 parent e2e8aed commit 7e4dd19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/zoekt-webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ func (s *loggedSearcher) log(ctx context.Context, q query.Q, opts *zoekt.SearchO
sglog.Int("stat.NgramMatches", st.NgramMatches),
sglog.Int("stat.NgramLookups", st.NgramLookups),
sglog.Duration("stat.Wait", st.Wait),
sglog.Int("stat.RegexpsConsidered", st.RegexpsConsidered),
sglog.String("stat.FlushReason", st.FlushReason.String()),
)
}

Expand Down
5 changes: 5 additions & 0 deletions shards/shards.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ var (
Name: "zoekt_search_ngram_lookups_total",
Help: "Total number of times we accessed an ngram in the index",
})
metricSearchRegexpsConsideredTotal = promauto.NewCounter(prometheus.CounterOpts{
Name: "zoekt_search_regexps_considered_total",
Help: "Total number of times regexp was called on files that we evaluated",
})

metricListRunning = promauto.NewGauge(prometheus.GaugeOpts{
Name: "zoekt_list_running",
Expand Down Expand Up @@ -826,6 +830,7 @@ func observeMetrics(sr *zoekt.SearchResult) {
metricSearchMatchCountTotal.Add(float64(sr.Stats.MatchCount))
metricSearchNgramMatchesTotal.Add(float64(sr.Stats.NgramMatches))
metricSearchNgramLookupsTotal.Add(float64(sr.Stats.NgramLookups))
metricSearchRegexpsConsideredTotal.Add(float64(sr.Stats.RegexpsConsidered))
}

func copySlice(src *[]byte) {
Expand Down

0 comments on commit 7e4dd19

Please sign in to comment.