set error status based on severity level of an error
This commit is contained in:
parent
f5819972a4
commit
265731010e
@ -4,6 +4,7 @@ import (
|
|||||||
"git.ma-al.com/maal-libraries/observer/pkg/attr"
|
"git.ma-al.com/maal-libraries/observer/pkg/attr"
|
||||||
"git.ma-al.com/maal-libraries/observer/pkg/level"
|
"git.ma-al.com/maal-libraries/observer/pkg/level"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -107,5 +108,8 @@ func NewErrInSpan[E IntoErrorEvent](err E, span trace.Span) E {
|
|||||||
er := err.IntoErrorEvent()
|
er := err.IntoErrorEvent()
|
||||||
er.extraSkipInStack += 1
|
er.extraSkipInStack += 1
|
||||||
span.RecordError(er.Err, er.AsOpts())
|
span.RecordError(er.Err, er.AsOpts())
|
||||||
|
if er.Level <= level.ERR {
|
||||||
|
span.SetStatus(codes.Error, er.Error())
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user