Logs. Add code to change span status.
This commit is contained in:
parent
f588822664
commit
aba3ad40a6
5
save.go
5
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
|
||||
|
|
Loading…
Reference in New Issue