Add logs for method DataCollection.Save.
This commit is contained in:
parent
b61bdcf676
commit
a4e2984934
|
@ -8,6 +8,7 @@ import (
|
|||
"git.bit5.ru/backend/meta"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
)
|
||||
|
||||
type DataCollection struct {
|
||||
|
@ -41,7 +42,10 @@ func (coll *DataCollection) Save(ctx context.Context) error {
|
|||
fields := coll.GetDbFields()
|
||||
countFields := len(fields)
|
||||
if countFields == 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
|
||||
}
|
||||
|
||||
countRows := len(coll.Items)
|
||||
|
@ -60,10 +64,21 @@ func (coll *DataCollection) Save(ctx context.Context) error {
|
|||
|
||||
// NOTE: performance fix: if none of rows have mask we can save all data by one sql query
|
||||
if allDataWithoutMask {
|
||||
return coll.saveWithoutMask(ctx)
|
||||
if err := coll.saveWithoutMask(ctx); err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return coll.saveByMask(ctx)
|
||||
if err := coll.saveByMask(ctx); err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (coll *DataCollection) saveByMask(ctx context.Context) error {
|
||||
|
|
Loading…
Reference in New Issue