From 7e4dd196133df7e9cac3e04b2d2fd1e1f21d8b4f Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Mon, 10 Jul 2023 16:36:07 +0200 Subject: [PATCH] all: observe missing Stats RegexpsConsidered and FlushReason Noticed we didn't include these fields in our prometheus and logging integration. Test Plan: go test ./... --- cmd/zoekt-webserver/main.go | 2 ++ shards/shards.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/cmd/zoekt-webserver/main.go b/cmd/zoekt-webserver/main.go index 92535e83b..0bc4872f7 100644 --- a/cmd/zoekt-webserver/main.go +++ b/cmd/zoekt-webserver/main.go @@ -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()), ) } diff --git a/shards/shards.go b/shards/shards.go index d844997a9..5bb6a2af1 100644 --- a/shards/shards.go +++ b/shards/shards.go @@ -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", @@ -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) {