diff --git a/redis_test.go b/redis_test.go index 4fa7a20..b68ca1a 100755 --- a/redis_test.go +++ b/redis_test.go @@ -12,6 +12,26 @@ import ( "go.unistack.org/micro/v3/tracer" ) +func TestLazyConnect(t *testing.T) { + ctx := context.Background() + var err error + + r := NewStore() + + if err = r.Init(); err != nil { + t.Fatal(err) + } + if err = r.Connect(ctx); err != nil { + t.Logf("connect failed %v", err) + } + + for { + if err = r.Write(ctx, "mykey", "myval"); err != nil { + t.Logf("failed to write %v", err) + } + } +} + func TestKeepTTL(t *testing.T) { ctx := context.Background() diff --git a/tracer.go b/tracer.go index 9df06fe..a038dab 100644 --- a/tracer.go +++ b/tracer.go @@ -73,7 +73,7 @@ func (h *tracingHook) ProcessHook(hook goredis.ProcessHook) goredis.ProcessHook case "cluster slots": break default: - _, span := h.tr.Start(ctx, "goredis.process", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...) + _, span := h.tr.Start(ctx, "sdk.database", append(h.opts, tracer.WithSpanLabels("db.statement", cmdString))...) defer func() { recordError(span, err) span.Finish() @@ -91,11 +91,11 @@ func (h *tracingHook) ProcessPipelineHook(hook goredis.ProcessPipelineHook) gore _, cmdsString := rediscmd.CmdsString(cmds) opts := append(h.opts, tracer.WithSpanLabels( - "db.goredis.num_cmd", strconv.Itoa(len(cmds)), + "db.database.num_cmd", strconv.Itoa(len(cmds)), "db.statement", cmdsString, )) - _, span := h.tr.Start(ctx, "goredis.process_pipeline", opts...) + _, span := h.tr.Start(ctx, "sdk.database", opts...) defer span.Finish() err := hook(ctx, cmds)