From 265731010ecc9495bbfcce3b62651721728b8be8 Mon Sep 17 00:00:00 2001 From: Natalia Goc Date: Mon, 20 May 2024 13:55:53 +0200 Subject: [PATCH] set error status based on severity level of an error --- pkg/event/event.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/event/event.go b/pkg/event/event.go index 6b3ac35..516bf89 100644 --- a/pkg/event/event.go +++ b/pkg/event/event.go @@ -4,6 +4,7 @@ import ( "git.ma-al.com/maal-libraries/observer/pkg/attr" "git.ma-al.com/maal-libraries/observer/pkg/level" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" ) @@ -107,5 +108,8 @@ func NewErrInSpan[E IntoErrorEvent](err E, span trace.Span) E { er := err.IntoErrorEvent() er.extraSkipInStack += 1 span.RecordError(er.Err, er.AsOpts()) + if er.Level <= level.ERR { + span.SetStatus(codes.Error, er.Error()) + } return err }