From f3d06886e64bb5343ce33bf62c8c02e499d4458b Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 9 Jul 2020 12:23:03 +0300 Subject: [PATCH] RecordError in OpenTelemetryHook --- redisext/otel.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/redisext/otel.go b/redisext/otel.go index 7e53f0b2..7a607b26 100644 --- a/redisext/otel.go +++ b/redisext/otel.go @@ -34,7 +34,11 @@ func (OpenTelemetryHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (co } func (OpenTelemetryHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error { - trace.SpanFromContext(ctx).End() + span := trace.SpanFromContext(ctx) + if err := cmd.Err(); err != nil { + internal.RecordError(ctx, err) + } + span.End() return nil } @@ -84,7 +88,11 @@ func (OpenTelemetryHook) BeforeProcessPipeline(ctx context.Context, cmds []redis } func (OpenTelemetryHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error { - trace.SpanFromContext(ctx).End() + span := trace.SpanFromContext(ctx) + if err := cmds[0].Err(); err != nil { + internal.RecordError(ctx, err) + } + span.End() return nil }