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:
parent
bb64c08185
commit
4707ea3f00
13
internal/utils/error.go
Normal file
13
internal/utils/error.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user