1
0
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:
Vladimir Mihailenco
2020-07-09 10:39:46 +03:00
parent dd5e03f960
commit 1831363467
3 changed files with 34 additions and 23 deletions

View File

@ -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
}