From aba3ad40a6bc35b825af47b714639b10d58d8f73 Mon Sep 17 00:00:00 2001 From: Vladislav Veselskiy Date: Tue, 5 Mar 2024 13:03:57 +0300 Subject: [PATCH] Logs. Add code to change span status. --- save.go | 5 +++++ 1 file changed, 5 insertions(+) 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