feat(exporter): add prometheus exporter for cache, database & webserver stats
This commit is contained in:
parent
95a3a16fdc
commit
4bbda96dc7
8 changed files with 405 additions and 18 deletions
9
internal/cache/cache.go
vendored
9
internal/cache/cache.go
vendored
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue