@@ -27,11 +27,16 @@ func (TracingHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.
27
27
return ctx , nil
28
28
}
29
29
30
- ctx , span := tracer .Start (ctx , cmd .FullName ())
31
- span .SetAttributes (
30
+ attrs := []attribute.KeyValue {
32
31
attribute .String ("db.system" , "redis" ),
33
32
attribute .String ("db.statement" , rediscmd .CmdString (cmd )),
34
- )
33
+ }
34
+ opts := []trace.SpanStartOption {
35
+ trace .WithSpanKind (trace .SpanKindClient ),
36
+ trace .WithAttributes (attrs ... ),
37
+ }
38
+
39
+ ctx , _ = tracer .Start (ctx , cmd .FullName (), opts ... )
35
40
36
41
return ctx , nil
37
42
}
@@ -52,12 +57,17 @@ func (TracingHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder
52
57
53
58
summary , cmdsString := rediscmd .CmdsString (cmds )
54
59
55
- ctx , span := tracer .Start (ctx , "pipeline " + summary )
56
- span .SetAttributes (
60
+ attrs := []attribute.KeyValue {
57
61
attribute .String ("db.system" , "redis" ),
58
62
attribute .Int ("db.redis.num_cmd" , len (cmds )),
59
63
attribute .String ("db.statement" , cmdsString ),
60
- )
64
+ }
65
+ opts := []trace.SpanStartOption {
66
+ trace .WithSpanKind (trace .SpanKindClient ),
67
+ trace .WithAttributes (attrs ... ),
68
+ }
69
+
70
+ ctx , _ = tracer .Start (ctx , "pipeline " + summary , opts ... )
61
71
62
72
return ctx , nil
63
73
}
0 commit comments