CLI Loading server stats and traces

This commit is contained in:
2024-10-01 23:33:18 +08:00
parent 632d37caf5
commit f66f144f2e
9 changed files with 208 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import (
"git.solsynth.dev/goatworks/roadsign/pkg/warden"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
"time"
)
func getStats(c *fiber.Ctx) error {
@ -23,5 +24,10 @@ func getStats(c *fiber.Ctx) error {
"locations": len(locations),
"destinations": len(destinations),
"applications": len(applications),
"uptime": time.Since(navi.R.Metrics.StartupAt).Milliseconds(),
"traffic": fiber.Map{
"total": navi.R.Metrics.TotalTraffic,
"unique_client": len(navi.R.Metrics.TrafficFrom),
},
})
}