Count hits, misses, fetches and transforms as Prometheus counters (closes #311)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The five counts the cache_stats table held are now Prometheus counters in memory, in internal/imgcache/counters.go, on the default registry that /metrics serves. The Increment methods add to them, 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 counters count for the whole process, so the tests that check how much they rose do not call t.Parallel. Two stop tests whose write under way was a hit count now use an access time. Model: opus-5-5
This commit is contained in:
@@ -142,8 +142,8 @@ var ErrProcessingTimedOut = errors.New(
|
||||
// only a request that needs the source fetched is refused.
|
||||
//
|
||||
// A cache hit opens the variant file and makes no database call: its access
|
||||
// time and its hit count are handed to the goroutine that
|
||||
// StartPendingCountWrites starts, without waiting for it. A variant file
|
||||
// time is handed to the goroutine that StartPendingAccessTimeWrites starts,
|
||||
// without waiting for it, and its hit is counted in memory. A variant file
|
||||
// that cannot be served, such as one whose first bytes are not those of an
|
||||
// output format, is a miss, and the variant is made again.
|
||||
func (s *Service) Get(
|
||||
@@ -196,11 +196,6 @@ func (s *Service) Warm(ctx context.Context, req *imagerequest.Request) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Stats returns cache statistics.
|
||||
func (s *Service) Stats(ctx context.Context) (*CacheStats, error) {
|
||||
return s.cache.Stats(ctx)
|
||||
}
|
||||
|
||||
// WaitForProcessing waits until no image is being processed, or until ctx
|
||||
// ends, and returns how many images were still being processed then.
|
||||
func (s *Service) WaitForProcessing(ctx context.Context) int {
|
||||
|
||||
Reference in New Issue
Block a user