Remove error reporting

This commit is contained in:
Vladimir Mihailenco 2020-04-19 08:12:57 +03:00
parent 66cd13e793
commit 2b060bb99d
1 changed files with 2 additions and 18 deletions

View File

@ -2,14 +2,11 @@ package internal
import (
"context"
"reflect"
"time"
"github.com/go-redis/redis/v8/internal/util"
"go.opentelemetry.io/otel/api/core"
"go.opentelemetry.io/otel/api/global"
"go.opentelemetry.io/otel/api/trace"
"google.golang.org/grpc/codes"
)
func Sleep(ctx context.Context, dur time.Duration) error {
@ -62,26 +59,13 @@ func Unwrap(err error) error {
return u.Unwrap()
}
var (
logTypeKey = core.Key("log.type")
logMessageKey = core.Key("log.message")
)
func WithSpan(ctx context.Context, name string, fn func(context.Context) error) error {
if !trace.SpanFromContext(ctx).IsRecording() {
return fn(ctx)
}
ctx, span := global.TraceProvider().Tracer("go-redis").Start(ctx, name)
ctx, span := global.Tracer("go-redis").Start(ctx, name)
defer span.End()
if err := fn(ctx); err != nil {
span.SetStatus(codes.Internal, err.Error())
span.AddEvent(ctx, "error",
logTypeKey.String(reflect.TypeOf(err).String()),
logMessageKey.String(err.Error()),
)
return err
}
return nil
return fn(ctx)
}