diff --git a/save.go b/save.go index 77206fc..8baa559 100644 --- a/save.go +++ b/save.go @@ -12,6 +12,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.12.0" "go.opentelemetry.io/otel/trace" ) @@ -169,11 +170,15 @@ func SaveMetaRootStruct( switch tfield.Kind() { case reflect.Slice: if err := SaveMetaCollection(ctx, db, dataItem.Field(i), ownerId, removedIds, deltaSave); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) return errors.WithMessagef(err, "Can not execute SaveMetaRootStruct. Got error from SaveMetaCollection. ownerId: %d.", ownerId) } break case reflect.Struct: if err := saveStruct(ctx, db, dataItem.Field(i), ownerId); err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) return errors.WithMessagef(err, "Can not execute SaveMetaRootStruct. Got error from saveStruct. ownerId: %d.", ownerId) } break