fixup duplicate nested redis span
Some checks failed
build / lint (push) Successful in 22s
build / test (push) Failing after 1m29s
codeql / analyze (go) (push) Failing after 1m52s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-07-05 12:59:05 +03:00
parent 4484cd34ec
commit 518cc1db73

View File

@ -55,10 +55,10 @@ func newTracingHook(connString string, tr tracer.Tracer, opts ...tracer.SpanOpti
func (h *tracingHook) DialHook(hook redis.DialHook) redis.DialHook { func (h *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
return func(ctx context.Context, network, addr string) (net.Conn, error) { return func(ctx context.Context, network, addr string) (net.Conn, error) {
sctx, span := h.tr.Start(ctx, "redis.dial", h.opts...) _, span := h.tr.Start(ctx, "redis.dial", h.opts...)
defer span.Finish() defer span.Finish()
conn, err := hook(sctx, network, addr) conn, err := hook(ctx, network, addr)
recordError(span, err) recordError(span, err)
return conn, err return conn, err
@ -69,10 +69,10 @@ func (h *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd redis.Cmder) error { return func(ctx context.Context, cmd redis.Cmder) error {
cmdString := rediscmd.CmdString(cmd) cmdString := rediscmd.CmdString(cmd)
sctx, span := h.tr.Start(ctx, "redis.process", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...) _, span := h.tr.Start(ctx, "redis.process", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...)
defer span.Finish() defer span.Finish()
err := hook(sctx, cmd) err := hook(ctx, cmd)
recordError(span, err) recordError(span, err)
return err return err
@ -88,10 +88,10 @@ func (h *tracingHook) ProcessPipelineHook(hook redis.ProcessPipelineHook) redis.
"db.statement", cmdsString, "db.statement", cmdsString,
)) ))
sctx, span := h.tr.Start(ctx, "redis.process_pipeline", opts...) _, span := h.tr.Start(ctx, "redis.process_pipeline", opts...)
defer span.Finish() defer span.Finish()
err := hook(sctx, cmds) err := hook(ctx, cmds)
recordError(span, err) recordError(span, err)
return err return err