feat(error): Add error handling utility function

Implement the HandleError function in the new error.go file to streamline error logging and tracing. Include necessary imports for context, logrus, and OpenTelemetry tracing.
This commit is contained in:
SoXX 2024-08-11 22:34:28 +02:00
parent bb64c08185
commit 4707ea3f00

13
internal/utils/error.go Normal file
View File

@ -0,0 +1,13 @@
package utils
import (
"context"
log "github.com/sirupsen/logrus"
"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)
span.RecordError(error)
return error
}