feat(tracing): Refactor error handling to include trace status update

This commit is contained in:
SoXX 2024-08-12 11:15:21 +02:00
parent 99ea2d37ab
commit 505bc3b522

View File

@ -2,12 +2,15 @@ package utils
import (
"context"
log "github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
)
func HandleError(ctx context.Context, span trace.Span, logger *log.Logger, fields log.Fields, error error) error {
logger.WithContext(ctx).WithFields(fields).Error(error)
func HandleError(ctx context.Context, span trace.Span, logger *log.Entry, error error) error {
logger.Error(error)
span.RecordError(error)
span.SetStatus(codes.Error, error.Error())
return error
}