Skip to content

Commit 25c1ea5

Browse files
authored
all: observe missing Stats RegexpsConsidered and FlushReason (#611)
Noticed we didn't include these fields in our prometheus and logging integration. Test Plan: go test ./...
1 parent e2e8aed commit 25c1ea5

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

cmd/zoekt-webserver/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ func (s *loggedSearcher) log(ctx context.Context, q query.Q, opts *zoekt.SearchO
596596
sglog.Int("stat.NgramMatches", st.NgramMatches),
597597
sglog.Int("stat.NgramLookups", st.NgramLookups),
598598
sglog.Duration("stat.Wait", st.Wait),
599+
sglog.Int("stat.RegexpsConsidered", st.RegexpsConsidered),
600+
sglog.String("stat.FlushReason", st.FlushReason.String()),
599601
)
600602
}
601603

shards/shards.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ var (
119119
Name: "zoekt_search_ngram_lookups_total",
120120
Help: "Total number of times we accessed an ngram in the index",
121121
})
122+
metricSearchRegexpsConsideredTotal = promauto.NewCounter(prometheus.CounterOpts{
123+
Name: "zoekt_search_regexps_considered_total",
124+
Help: "Total number of times regexp was called on files that we evaluated",
125+
})
122126

123127
metricListRunning = promauto.NewGauge(prometheus.GaugeOpts{
124128
Name: "zoekt_list_running",
@@ -826,6 +830,7 @@ func observeMetrics(sr *zoekt.SearchResult) {
826830
metricSearchMatchCountTotal.Add(float64(sr.Stats.MatchCount))
827831
metricSearchNgramMatchesTotal.Add(float64(sr.Stats.NgramMatches))
828832
metricSearchNgramLookupsTotal.Add(float64(sr.Stats.NgramLookups))
833+
metricSearchRegexpsConsideredTotal.Add(float64(sr.Stats.RegexpsConsidered))
829834
}
830835

831836
func copySlice(src *[]byte) {

0 commit comments

Comments
 (0)