mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
Add RecordError
This commit is contained in:
@ -62,17 +62,6 @@ func Unwrap(err error) error {
|
||||
return u.Unwrap()
|
||||
}
|
||||
|
||||
func WithSpan(ctx context.Context, name string, fn func(context.Context) error) error {
|
||||
if !trace.SpanFromContext(ctx).IsRecording() {
|
||||
return fn(ctx)
|
||||
}
|
||||
|
||||
ctx, span := global.Tracer("go-redis").Start(ctx, name)
|
||||
defer span.End()
|
||||
|
||||
return fn(ctx)
|
||||
}
|
||||
|
||||
func AppendArg(b []byte, v interface{}) []byte {
|
||||
switch v := v.(type) {
|
||||
case nil:
|
||||
@ -143,3 +132,21 @@ func appendRune(b []byte, r rune) []byte {
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func WithSpan(ctx context.Context, name string, fn func(context.Context) error) error {
|
||||
if !trace.SpanFromContext(ctx).IsRecording() {
|
||||
return fn(ctx)
|
||||
}
|
||||
|
||||
ctx, span := global.Tracer("github.com/go-redis/redis").Start(ctx, name)
|
||||
defer span.End()
|
||||
|
||||
return fn(ctx)
|
||||
}
|
||||
|
||||
func RecordError(ctx context.Context, err error) error {
|
||||
trace.SpanFromContext(ctx).RecordError(ctx, err)
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user