feat: Add tracing events and logging for batch processing steps
This commit is contained in:
parent
b2db0664d6
commit
44137a7251
@ -72,7 +72,7 @@ outer:
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
break outer
|
break outer
|
||||||
default:
|
default:
|
||||||
|
summery := BatchSummery{}
|
||||||
span.AddEvent("Executing getFavorites request")
|
span.AddEvent("Executing getFavorites request")
|
||||||
favorites, err := plugInterface.GetFavoritePage(ctx, apiKey, userSource, nextPage)
|
favorites, err := plugInterface.GetFavoritePage(ctx, apiKey, userSource, nextPage)
|
||||||
span.AddEvent("Finished executing getFavorites request")
|
span.AddEvent("Finished executing getFavorites request")
|
||||||
@ -89,8 +89,9 @@ outer:
|
|||||||
break outer
|
break outer
|
||||||
}
|
}
|
||||||
|
|
||||||
summery := BatchSummery{}
|
span.AddEvent("Executing BatchPostProcessingWithSummery")
|
||||||
newPosts, anthroveFaves, summery, err = BatchPostProcessingWithSummery(ctx, userSource, favorites.Posts)
|
newPosts, anthroveFaves, summery, err = BatchPostProcessingWithSummery(ctx, userSource, favorites.Posts)
|
||||||
|
span.AddEvent("Finished executing BatchPostProcessingWithSummery")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
span.SetStatus(codes.Error, err.Error())
|
span.SetStatus(codes.Error, err.Error())
|
||||||
@ -98,6 +99,12 @@ outer:
|
|||||||
return taskSummery, err
|
return taskSummery, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(anthroveFaves) > 0 {
|
||||||
|
span.AddEvent("No more favorites found to add")
|
||||||
|
log.WithContext(ctx).WithFields(basicLoggingInfo).Info("No more favorites found")
|
||||||
|
break outer
|
||||||
|
}
|
||||||
|
|
||||||
nextPage = favorites.NextPage
|
nextPage = favorites.NextPage
|
||||||
taskSummery.AddedPosts += int(summery.AddedFavorites)
|
taskSummery.AddedPosts += int(summery.AddedFavorites)
|
||||||
}
|
}
|
||||||
@ -106,6 +113,7 @@ outer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(newPosts) > 0 {
|
if len(newPosts) > 0 {
|
||||||
|
span.AddEvent("Executing CreatePostInBatch")
|
||||||
err = database.CreatePostInBatch(ctx, newPosts, BatchSize)
|
err = database.CreatePostInBatch(ctx, newPosts, BatchSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
@ -118,6 +126,8 @@ outer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(anthroveFaves) > 0 {
|
if len(anthroveFaves) > 0 {
|
||||||
|
span.AddEvent("Executing CreateUserFavoriteInBatch")
|
||||||
|
|
||||||
slices.Reverse(anthroveFaves)
|
slices.Reverse(anthroveFaves)
|
||||||
err = database.CreateUserFavoriteInBatch(ctx, anthroveFaves, BatchSize)
|
err = database.CreateUserFavoriteInBatch(ctx, anthroveFaves, BatchSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user