Count hits, misses, fetches and transforms as Prometheus counters (closes #311)
check / check (push) Waiting to run

The five counts the cache_stats table held are now Prometheus counters in
memory, as fields of the cache. NewCache makes them and registers them on
the registry it is given. pixad gives it Prometheus' default registry,
which /metrics serves; each test gives it a new one. The Increment methods
add to their cache's counters, so counting makes no database call.

cache_stats, Cache.Stats, Service.Stats, CacheStats and the pending counts
are gone, with their tests. The background goroutine now writes only access
times, and its names say so: StartPendingAccessTimeWrites,
StopPendingAccessTimeWrites and pendingaccesstimes.go. The two stop tests
whose write under way was a count now use access times.

Model: opus-5-5
This commit is contained in:
2026-10-26 09:12:33 +00:00
parent 6b19e4c96c
commit 018c12a8d2
37 changed files with 835 additions and 1195 deletions
+2
View File
@@ -9,6 +9,7 @@ import (
"strings"
"testing"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/fx"
"go.uber.org/fx/fxtest"
@@ -46,6 +47,7 @@ func startPixa(t *testing.T, cfg *config.Config) *Server {
healthcheck.New,
handlers.New,
middleware.New,
func() prometheus.Registerer { return prometheus.NewRegistry() },
),
fx.Populate(&h, &mw),
)