Add logs for method DataCollection.saveWithoutMask.

This commit is contained in:
Владислав Весельский 2024-03-13 15:33:59 +03:00
parent 5af4d90edb
commit 328bac49e0
1 changed files with 9 additions and 3 deletions

View File

@ -146,7 +146,7 @@ func (coll *DataCollection) saveWithoutMask(ctx context.Context) error {
countRows := len(coll.Items) countRows := len(coll.Items)
span.SetAttributes( span.SetAttributes(
attribute.String("db.sql.table", tableName), attribute.String("table", tableName),
attribute.Int("field_amount", countFields), attribute.Int("field_amount", countFields),
attribute.Int("item_amount", countRows), attribute.Int("item_amount", countRows),
) )
@ -161,7 +161,10 @@ func (coll *DataCollection) saveWithoutMask(ctx context.Context) error {
if ownerValue == uint32(0) { if ownerValue == uint32(0) {
rows[start+coll.ownerFieldIndex] = coll.OwnerId rows[start+coll.ownerFieldIndex] = coll.OwnerId
} else if ownerValue != coll.OwnerId { } else if ownerValue != coll.OwnerId {
return errors.Errorf("Wrong owner_id in %s value %d (!= %d)", tableName, ownerValue, coll.OwnerId) err := errors.Errorf("Wrong owner_id in %s value %d (!= %d)", tableName, ownerValue, coll.OwnerId)
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return err
} }
offset++ offset++
} }
@ -169,7 +172,10 @@ func (coll *DataCollection) saveWithoutMask(ctx context.Context) error {
sqlSmt := createInsertSQLForFields(ctx, tableName, fields, countRows) sqlSmt := createInsertSQLForFields(ctx, tableName, fields, countRows)
_, err := coll.Db.UpdateBySQL(sqlSmt, rows...).Exec() _, err := coll.Db.UpdateBySQL(sqlSmt, rows...).Exec()
if err != nil { if err != nil {
return errors.Errorf("error: %s, sql: %s", err.Error(), sqlSmt) resultErr := errors.Errorf("error: %s, sql: %s", err.Error(), sqlSmt)
span.RecordError(resultErr)
span.SetStatus(codes.Error, resultErr.Error())
return resultErr
} }
return nil return nil
} }