feat(tracing): Refactor error handling to include trace status update
This commit is contained in:
parent
99ea2d37ab
commit
505bc3b522
@ -2,12 +2,15 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"go.opentelemetry.io/otel/codes"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HandleError(ctx context.Context, span trace.Span, logger *log.Logger, fields log.Fields, error error) error {
|
func HandleError(ctx context.Context, span trace.Span, logger *log.Entry, error error) error {
|
||||||
logger.WithContext(ctx).WithFields(fields).Error(error)
|
logger.Error(error)
|
||||||
span.RecordError(error)
|
span.RecordError(error)
|
||||||
|
span.SetStatus(codes.Error, error.Error())
|
||||||
return error
|
return error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user