Added Scrape History Logging #9
@ -71,14 +71,14 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
|
|||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
span.SetStatus(codes.Error, err.Error())
|
span.SetStatus(codes.Error, err.Error())
|
||||||
|
|
||||||
err = database.UpdateScrapeHistory(ctx, models.ScrapeHistory{
|
dberr := database.UpdateScrapeHistory(ctx, models.ScrapeHistory{
|
||||||
ScrapeTaskID: models.ScrapeTaskID(id),
|
ScrapeTaskID: models.ScrapeTaskID(id),
|
||||||
UserSourceID: userSource.ID,
|
UserSourceID: userSource.ID,
|
||||||
FinishedAt: time.Now(),
|
FinishedAt: time.Now(),
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil, err
|
return nil, errors.Join(err, dberr)
|
||||||
}
|
}
|
||||||
span.AddEvent("Retrieved user source", trace.WithAttributes(attribute.String("user_source_id", creation.UserSourceId)))
|
span.AddEvent("Retrieved user source", trace.WithAttributes(attribute.String("user_source_id", creation.UserSourceId)))
|
||||||
|
|
||||||
@ -91,14 +91,14 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
|
|||||||
|
|
||||||
plugTaskState.TaskState = gRPC.PlugTaskState_STOPPED
|
plugTaskState.TaskState = gRPC.PlugTaskState_STOPPED
|
||||||
|
|
||||||
err = database.UpdateScrapeHistory(ctx, models.ScrapeHistory{
|
dberr := database.UpdateScrapeHistory(ctx, models.ScrapeHistory{
|
||||||
ScrapeTaskID: models.ScrapeTaskID(id),
|
ScrapeTaskID: models.ScrapeTaskID(id),
|
||||||
UserSourceID: userSource.ID,
|
UserSourceID: userSource.ID,
|
||||||
FinishedAt: time.Now(),
|
FinishedAt: time.Now(),
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
})
|
})
|
||||||
|
|
||||||
return &plugTaskState, err
|
return &plugTaskState, errors.Join(err, dberr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// gRPC closes the context after the call ended. So the whole scrapping stopped without waiting
|
// gRPC closes the context after the call ended. So the whole scrapping stopped without waiting
|
||||||
|
Loading…
Reference in New Issue
Block a user