From 6aec2c70ce4aff99f240554ef7cdfed3adca4dac Mon Sep 17 00:00:00 2001 From: msaf1980 Date: Sat, 5 Nov 2022 13:46:45 +0500 Subject: [PATCH] autocomplete: separate requests metrics --- autocomplete/autocomplete.go | 4 ++-- config/config_test.go | 1 + metrics/metrics.go | 2 ++ metrics/metrics_test.go | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/autocomplete/autocomplete.go b/autocomplete/autocomplete.go index 6dc050864..9e0d80a76 100644 --- a/autocomplete/autocomplete.go +++ b/autocomplete/autocomplete.go @@ -149,7 +149,7 @@ func (h *Handler) ServeTags(w http.ResponseWriter, r *http.Request) { http.Error(w, answer, status) } d := time.Since(start).Milliseconds() - metrics.SendFindMetrics(metrics.FindRequestMetric, status, d, 0, h.config.Metrics.ExtendedStat, metricsCount) + metrics.SendFindMetrics(metrics.TagsRequestMetric, status, d, 0, h.config.Metrics.ExtendedStat, metricsCount) if !findCache && chReadRows != 0 && chReadBytes != 0 { errored := status != http.StatusOK && status != http.StatusNotFound metrics.SendQueryRead(metrics.AutocompleteQMetric, 0, 0, d, metricsCount, readBytes, chReadRows, chReadBytes, errored) @@ -332,7 +332,7 @@ func (h *Handler) ServeValues(w http.ResponseWriter, r *http.Request) { http.Error(w, answer, status) } d := time.Since(start).Milliseconds() - metrics.SendFindMetrics(metrics.FindRequestMetric, status, d, 0, h.config.Metrics.ExtendedStat, metricsCount) + metrics.SendFindMetrics(metrics.TagsRequestMetric, status, d, 0, h.config.Metrics.ExtendedStat, metricsCount) if !findCache && chReadRows > 0 && chReadBytes > 0 { errored := status != http.StatusOK && status != http.StatusNotFound metrics.SendQueryRead(metrics.AutocompleteQMetric, 0, 0, d, metricsCount, int64(len(body)), chReadRows, chReadBytes, errored) diff --git a/config/config_test.go b/config/config_test.go index 037879f53..e6c7203a6 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -659,6 +659,7 @@ sample-thereafter = 12 assert.Equal(t, expected.Logging, config.Logging) metrics.FindRequestMetric = nil + metrics.TagsRequestMetric = nil metrics.RenderRequestMetric = nil metrics.UnregisterAll() } diff --git a/metrics/metrics.go b/metrics/metrics.go index 831e64090..aece1d66e 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -77,6 +77,7 @@ type RenderMetrics struct { var RenderRequestMetric *RenderMetrics var FindRequestMetric *FindMetrics +var TagsRequestMetric *FindMetrics func initFindCacheMetrics(c *Config) { FinderCacheMetrics = &CacheMetric{ @@ -581,6 +582,7 @@ func InitMetrics(c *Config) { } initFindCacheMetrics(c) FindRequestMetric = initFindMetrics("find", c) + TagsRequestMetric = initFindMetrics("tags", c) RenderRequestMetric = initRenderMetrics("render", c) } diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index 6276f5c21..f6cfd72bf 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -433,6 +433,7 @@ func TestInitMetrics(t *testing.T) { for n, tt := range tests { t.Run(tt.name+"#"+strconv.Itoa(n), func(t *testing.T) { FindRequestMetric = nil + TagsRequestMetric = nil RenderRequestMetric = nil UnregisterAll() c := tt.c