-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathdebug.go
More file actions
48 lines (41 loc) · 1.27 KB
/
debug.go
File metadata and controls
48 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//go:build debug
package main
import (
"time"
"github.com/fjl/memsize"
"github.com/fjl/memsize/memsizeui"
"github.com/flanksource/config-db/api"
"github.com/flanksource/config-db/db"
"github.com/flanksource/config-db/scrapers"
"github.com/flanksource/config-db/scrapers/kubernetes"
"github.com/flanksource/config-db/utils"
"github.com/labstack/echo/v4"
)
func init() {
var memsizeHandler memsizeui.Handler
utils.TrackObject = func(name string, obj any) {
if obj == nil {
go func() {
time.Sleep(5 * time.Minute)
utils.TrackObject(name, obj)
}()
} else {
memsizeHandler.Add(name, obj)
}
}
utils.MemsizeScan = func(obj any) uintptr {
sizes := memsize.Scan(obj)
return sizes.Total
}
utils.MemsizeEchoHandler = func(c echo.Context) error {
memsizeHandler.ServeHTTP(c.Response(), c.Request())
return nil
}
utils.TrackObject("TempCacheStore", &scrapers.TempCacheStore)
utils.TrackObject("ScraperTempCache", &api.ScraperTempCache)
utils.TrackObject("IgnoreCache", &kubernetes.IgnoreCache)
utils.TrackObject("OrphanCache", &db.OrphanCache)
utils.TrackObject("ChangeCacheByFingerprint", &db.ChangeCacheByFingerprint)
utils.TrackObject("ParentCache", &db.ParentCache)
utils.TrackObject("ResourceIDMapPerCluster", &kubernetes.ResourceIDMapPerCluster)
}