From b263e140327e6e47a9bf1c035e770113b8265657 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 5 Jul 2024 13:44:29 +0300 Subject: [PATCH] cleanup trace spans from cluster slots command Signed-off-by: Vasiliy Tolstov --- tracer.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tracer.go b/tracer.go index 60d8fea..6ca14d6 100644 --- a/tracer.go +++ b/tracer.go @@ -68,12 +68,20 @@ func (h *tracingHook) DialHook(hook redis.DialHook) redis.DialHook { func (h *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook { return func(ctx context.Context, cmd redis.Cmder) error { cmdString := rediscmd.CmdString(cmd) + var err error - _, span := h.tr.Start(ctx, "redis.process", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...) - defer span.Finish() + switch cmdString { + case "cluster slots": + break + default: + _, span := h.tr.Start(ctx, "redis.process", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...) + defer func() { + recordError(span, err) + span.Finish() + }() + } - err := hook(ctx, cmd) - recordError(span, err) + err = hook(ctx, cmd) return err }