Skip to content

Commit

Permalink
Improve error log message in worker
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Nov 8, 2023
1 parent f2849ca commit d7437f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ func (w *Worker) Run(c chan model.Job) {
)

startTime := time.Now()
refreshErr := feedHandler.RefreshFeed(w.store, job.UserID, job.FeedID, false)
localizedError := feedHandler.RefreshFeed(w.store, job.UserID, job.FeedID, false)

if config.Opts.HasMetricsCollector() {
status := "success"
if refreshErr != nil {
if localizedError != nil {
status = "error"
}
metric.BackgroundFeedRefreshDuration.WithLabelValues(status).Observe(time.Since(startTime).Seconds())
}

if refreshErr != nil {
if localizedError != nil {
slog.Warn("Unable to refresh a feed",
slog.Int64("user_id", job.UserID),
slog.Int64("feed_id", job.FeedID),
slog.Any("error", refreshErr),
slog.Any("error", localizedError.Error()),
)
}
}
Expand Down

0 comments on commit d7437f1

Please sign in to comment.