feat(exporter): add prometheus exporter for cache, database & webserver stats

This commit is contained in:
Tom Neuber 2024-11-28 11:53:40 +01:00
parent 95a3a16fdc
commit 4bbda96dc7
Signed by: tom
GPG key ID: F17EFE4272D89FF6
8 changed files with 405 additions and 18 deletions

View file

@ -16,6 +16,15 @@ func NewCache(ttl time.Duration) *Cache {
}
}
func (c *Cache) Count() uint {
var counter uint
c.store.Range(func(_, _ any) bool {
counter++
return true
})
return counter
}
func (c *Cache) Set(key, value uint) {
c.store.Store(key, value)
time.AfterFunc(c.ttl, func() {