1
0
forked from wrenn/wrenn

Add daily usage metrics (CPU-minutes, RAM GB-minutes)

Introduce pre-computed daily usage rollups from sandbox_metrics_snapshots.
An hourly background worker aggregates completed days, while today's
usage is computed live from snapshots at query time for freshness.

Backend: new daily_usage table, rollup worker, UsageService, and
GET /v1/capsules/usage endpoint with date range filtering (up to 92 days).

Frontend: replace Usage page placeholder with bar charts (Chart.js),
summary total cards, and preset/custom date range controls.
This commit is contained in:
2026-04-18 14:29:09 +06:00
parent e7670e4449
commit 92aab09104
12 changed files with 983 additions and 92 deletions

View File

@ -210,6 +210,10 @@ func Run(opts ...Option) {
sampler := api.NewMetricsSampler(queries, 10*time.Second)
sampler.Start(ctx)
// Start daily usage rollup (pre-computes CPU-minutes and RAM-MB-minutes).
rollup := api.NewDailyUsageRollup(queries, time.Hour)
rollup.Start(ctx)
// Start extension background workers.
for _, ext := range o.extensions {
for _, worker := range ext.BackgroundWorkers(sctx) {