chore(tracing): Update log field names for clarity

This commit is contained in:
SoXX 2024-08-12 09:57:31 +02:00
parent c17b78cc48
commit 6bec8e3373

View File

@ -3,6 +3,7 @@ package database
import (
"context"
"errors"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/internal/utils"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/error"
"git.anthrove.art/Anthrove/otter-space-sdk/v2/pkg/models"
@ -32,8 +33,8 @@ func CreateTag(ctx context.Context, tagName models.TagName, tagType models.TagTy
}
logger.WithContext(ctx).WithFields(log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}).Debug("attempting to create tag")
result := client.WithContext(ctx).Create(&tag)
@ -41,22 +42,22 @@ func CreateTag(ctx context.Context, tagName models.TagName, tagType models.TagTy
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
loggerFields := log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}
return models.Tag{}, utils.HandleError(ctx, span, logger, loggerFields, &otterError.Database{Reason: otterError.DuplicateKey})
}
loggerFields := log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}
return models.Tag{}, utils.HandleError(ctx, span, logger, loggerFields, result.Error)
}
logger.WithContext(ctx).WithFields(log.Fields{
"name": tagName,
"type": tagType,
"tag_name": tagName,
"tag_type": tagType,
}).Debug("tag created")
span.AddEvent("Tag created successfully")
return tag, nil