diff --git a/save.go b/save.go index e88fe34..c0053ad 100644 --- a/save.go +++ b/save.go @@ -49,6 +49,8 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { info, err := makeDataRowInfo(dataItem) if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) return err } @@ -77,7 +79,10 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { } if len(fields) == 0 { - return errors.New("Fields list is empty") + err := errors.New("Fields list is empty") + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) + return err } tableName := info.tableName @@ -97,7 +102,11 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { if len(sqlSmt) > 200 { sqlSmt = sqlSmt[0:200] } - return errors.Errorf("Can not execute SaveRow. Got error from updateBuilder.ExecContext. %s (%s)", err.Error(), sqlSmt) + + resultErr := errors.Errorf("Can not execute SaveRow. Got error from updateBuilder.ExecContext. %s (%s)", err.Error(), sqlSmt) + span.RecordError(resultErr) + span.SetStatus(codes.Error, resultErr.Error()) + return resultErr } insertId, _ := res.LastInsertId()