From 7dc8f598c369d718ed0a49be2b36c59047e5c31e Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 22 Jan 2026 10:50:03 +1100 Subject: [PATCH] more logging in daily aggregation --- internal/tasks/dailyAggregate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/tasks/dailyAggregate.go b/internal/tasks/dailyAggregate.go index 2b4564a..109afa5 100644 --- a/internal/tasks/dailyAggregate.go +++ b/internal/tasks/dailyAggregate.go @@ -26,6 +26,7 @@ func (c *CronTask) RunVcenterDailyAggregate(ctx context.Context, logger *slog.Lo }() // Aggregate the previous day to avoid partial "today" data when the job runs just after midnight. targetTime := time.Now().AddDate(0, 0, -1) + logger.Info("Daily summary job starting", "target_date", targetTime.Format("2006-01-02")) // Always force regeneration on the scheduled run to refresh data even if a manual run happened earlier. return c.aggregateDailySummary(jobCtx, targetTime, true) }) @@ -39,6 +40,7 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti jobStart := time.Now() dayStart := time.Date(targetTime.Year(), targetTime.Month(), targetTime.Day(), 0, 0, 0, 0, targetTime.Location()) dayEnd := dayStart.AddDate(0, 0, 1) + c.Logger.Info("Daily aggregation window", "start", dayStart, "end", dayEnd) summaryTable, err := dailySummaryTableName(targetTime) if err != nil { return err @@ -81,6 +83,7 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti } hourlySnapshots = filterRecordsInRange(hourlySnapshots, dayStart, dayEnd) hourlySnapshots = filterSnapshotsWithRows(ctx, dbConn, hourlySnapshots) + c.Logger.Info("Daily aggregation hourly snapshot count", "count", len(hourlySnapshots), "date", dayStart.Format("2006-01-02")) if len(hourlySnapshots) == 0 { return fmt.Errorf("no hourly snapshot tables found for %s", dayStart.Format("2006-01-02")) } @@ -196,6 +199,7 @@ func (c *CronTask) aggregateDailySummaryGo(ctx context.Context, dayStart, dayEnd } hourlySnapshots = filterRecordsInRange(hourlySnapshots, dayStart, dayEnd) hourlySnapshots = filterSnapshotsWithRows(ctx, dbConn, hourlySnapshots) + c.Logger.Info("Daily aggregation hourly snapshot count (go path)", "count", len(hourlySnapshots), "date", dayStart.Format("2006-01-02")) if len(hourlySnapshots) == 0 { return fmt.Errorf("no hourly snapshot tables found for %s", dayStart.Format("2006-01-02")) } else {