SDK v3 #8

Merged
SoXX merged 77 commits from dev/issue-5 into main 2024-08-14 13:27:35 +00:00
Showing only changes of commit 098ecda869 - Show all commits

View File

@ -69,10 +69,10 @@ func CreateTagAliasInBatch(ctx context.Context, tagsAliases []models.TagAlias, b
span.SetAttributes(
attribute.Int64("batch_size", int64(batchSize)),
attribute.Int64("tag_count", int64(len(tagsAliases))),
attribute.Int64("tag_aliases_count", int64(len(tagsAliases))),
)
span.AddEvent("Starting batch tag creation")
span.AddEvent("Starting batch tag alias creation")
if client == nil {
return utils.HandleError(ctx, span, logger, nil, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
@ -87,26 +87,26 @@ func CreateTagAliasInBatch(ctx context.Context, tagsAliases []models.TagAlias, b
}
logger.WithContext(ctx).WithFields(log.Fields{
"tag_alias_length": len(tagsAliases),
"tag_aliases_count": len(tagsAliases),
}).Debug("attempting to create tags aliases")
result := client.WithContext(ctx).CreateInBatches(&tagsAliases, batchSize)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
loggerFields := log.Fields{
"tag_alias_length": len(tagsAliases),
"tag_aliases_count": len(tagsAliases),
}
return utils.HandleError(ctx, span, logger, loggerFields, &otterError.Database{Reason: otterError.DuplicateKey})
}
loggerFields := log.Fields{
"tag_alias_length": len(tagsAliases),
"tag_aliases_count": len(tagsAliases),
}
return utils.HandleError(ctx, span, logger, loggerFields, result.Error)
}
logger.WithContext(ctx).WithFields(log.Fields{
"tag_alias_length": len(tagsAliases),
"tag_aliases_count": len(tagsAliases),
}).Debug("batch tags aliases created")
span.AddEvent("Batch tags aliases created successfully")