more logging in daily aggregation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nathan Coad
2026-01-22 10:50:03 +11:00
parent 148df38219
commit 7dc8f598c3

View File

@@ -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. // Aggregate the previous day to avoid partial "today" data when the job runs just after midnight.
targetTime := time.Now().AddDate(0, 0, -1) 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. // Always force regeneration on the scheduled run to refresh data even if a manual run happened earlier.
return c.aggregateDailySummary(jobCtx, targetTime, true) return c.aggregateDailySummary(jobCtx, targetTime, true)
}) })
@@ -39,6 +40,7 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti
jobStart := time.Now() jobStart := time.Now()
dayStart := time.Date(targetTime.Year(), targetTime.Month(), targetTime.Day(), 0, 0, 0, 0, targetTime.Location()) dayStart := time.Date(targetTime.Year(), targetTime.Month(), targetTime.Day(), 0, 0, 0, 0, targetTime.Location())
dayEnd := dayStart.AddDate(0, 0, 1) dayEnd := dayStart.AddDate(0, 0, 1)
c.Logger.Info("Daily aggregation window", "start", dayStart, "end", dayEnd)
summaryTable, err := dailySummaryTableName(targetTime) summaryTable, err := dailySummaryTableName(targetTime)
if err != nil { if err != nil {
return err return err
@@ -81,6 +83,7 @@ func (c *CronTask) aggregateDailySummary(ctx context.Context, targetTime time.Ti
} }
hourlySnapshots = filterRecordsInRange(hourlySnapshots, dayStart, dayEnd) hourlySnapshots = filterRecordsInRange(hourlySnapshots, dayStart, dayEnd)
hourlySnapshots = filterSnapshotsWithRows(ctx, dbConn, hourlySnapshots) 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 { if len(hourlySnapshots) == 0 {
return fmt.Errorf("no hourly snapshot tables found for %s", dayStart.Format("2006-01-02")) 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 = filterRecordsInRange(hourlySnapshots, dayStart, dayEnd)
hourlySnapshots = filterSnapshotsWithRows(ctx, dbConn, hourlySnapshots) 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 { if len(hourlySnapshots) == 0 {
return fmt.Errorf("no hourly snapshot tables found for %s", dayStart.Format("2006-01-02")) return fmt.Errorf("no hourly snapshot tables found for %s", dayStart.Format("2006-01-02"))
} else { } else {