From 3e8f58dc6c6f0b4824d6d09aa87ee3f2feeeef74 Mon Sep 17 00:00:00 2001 From: Martijn de Gouw Date: Wed, 11 Oct 2023 21:19:24 +0200 Subject: [PATCH] [metrics] initialize hits/misses for each cache entry kind This makes sure all hit/miss counters appear on the metrics endpoints and avoids having to fill missing metrics with zero at the client side. --- cache/disk/options.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cache/disk/options.go b/cache/disk/options.go index 06416a1b9..9d286569f 100644 --- a/cache/disk/options.go +++ b/cache/disk/options.go @@ -98,6 +98,13 @@ func WithEndpointMetrics() Option { []string{"method", "kind", "status"}), } + c.metrics.counter.WithLabelValues("get", "cas", "hit").Add(0) + c.metrics.counter.WithLabelValues("get", "cas", "miss").Add(0) + c.metrics.counter.WithLabelValues("contains", "cas", "hit").Add(0) + c.metrics.counter.WithLabelValues("contains", "cas", "miss").Add(0) + c.metrics.counter.WithLabelValues("get", "ac", "hit").Add(0) + c.metrics.counter.WithLabelValues("get", "ac", "miss").Add(0) + return nil } }