feat(metrics): add cache, process and http metrics

This commit is contained in:
TheFox0x7
2025-01-23 20:00:33 +01:00
parent e94f37f95e
commit 73266df0f5
4 changed files with 58 additions and 0 deletions
+6
View File
@@ -6,6 +6,7 @@ package cache
import (
"errors"
"strings"
"time"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/setting"
@@ -63,10 +64,15 @@ func (sc *stringCache) Ping() error {
}
func (sc *stringCache) Get(key string) (string, bool) {
start := time.Now()
v := sc.chiCache.Get(key)
elapsed := time.Since(start).Seconds()
latencyHistogram.Observe(elapsed)
if v == nil {
missCounter.Add(1)
return "", false
}
hitCounter.Add(1)
s, ok := v.(string)
return s, ok
}