Added Scrape History Logging #9

Merged
SoXX merged 6 commits from dev/scrape-history into main 2024-10-16 10:15:59 +00:00
Showing only changes of commit cc2b0374da - Show all commits

View File

@ -130,10 +130,11 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
ScrapeTaskID: models.ScrapeTaskID(id), ScrapeTaskID: models.ScrapeTaskID(id),
UserSourceID: userSource.ID, UserSourceID: userSource.ID,
FinishedAt: time.Now(), FinishedAt: time.Now(),
Error: err.Error(), Error: errorString(err),
AddedPosts: taskSummery.AddedPosts, AddedPosts: taskSummery.AddedPosts,
DeletedPosts: taskSummery.DeletedPosts, DeletedPosts: taskSummery.DeletedPosts,
}) })
if err != nil { if err != nil {
log.WithContext(taskCtx).WithError(err).WithField("task_id", id).Error("Task execution failed") log.WithContext(taskCtx).WithError(err).WithField("task_id", id).Error("Task execution failed")
span.RecordError(err) span.RecordError(err)
@ -293,3 +294,10 @@ func (s *server) removeTask(taskID string) {
fn() fn()
delete(s.ctx, taskID) delete(s.ctx, taskID)
} }
func errorString(err error) string {
if err != nil {
return err.Error()
}
return ""
}