@@ -27,11 +27,16 @@ func (TracingHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.
2727 return ctx , nil
2828 }
2929
30- ctx , span := tracer .Start (ctx , cmd .FullName ())
31- span .SetAttributes (
30+ attrs := []attribute.KeyValue {
3231 attribute .String ("db.system" , "redis" ),
3332 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 ... )
3540
3641 return ctx , nil
3742}
@@ -52,12 +57,17 @@ func (TracingHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder
5257
5358 summary , cmdsString := rediscmd .CmdsString (cmds )
5459
55- ctx , span := tracer .Start (ctx , "pipeline " + summary )
56- span .SetAttributes (
60+ attrs := []attribute.KeyValue {
5761 attribute .String ("db.system" , "redis" ),
5862 attribute .Int ("db.redis.num_cmd" , len (cmds )),
5963 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 ... )
6171
6272 return ctx , nil
6373}
0 commit comments