add prometheus instrumentation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-15 11:43:29 +11:00
parent 4d754ee263
commit ea68331208
9 changed files with 193 additions and 42 deletions

View File

@@ -6,6 +6,7 @@ import (
"log/slog"
"time"
"vctp/db"
"vctp/internal/metrics"
"vctp/internal/report"
)
@@ -29,6 +30,7 @@ func (c *CronTask) AggregateMonthlySummary(ctx context.Context, month time.Time,
}
func (c *CronTask) aggregateMonthlySummary(ctx context.Context, targetMonth time.Time, force bool) error {
jobStart := time.Now()
if err := report.EnsureSnapshotRegistry(ctx, c.Database); err != nil {
return err
}
@@ -107,9 +109,12 @@ func (c *CronTask) aggregateMonthlySummary(ctx context.Context, targetMonth time
if err := c.generateReport(ctx, monthlyTable); err != nil {
c.Logger.Warn("failed to generate monthly report", "error", err, "table", monthlyTable)
metrics.RecordMonthlyAggregation(time.Since(jobStart), err)
return err
}
c.Logger.Debug("Finished monthly inventory aggregation", "summary_table", monthlyTable)
metrics.RecordMonthlyAggregation(time.Since(jobStart), nil)
return nil
}